You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2012/02/27 13:12:32 UTC
DO NOT REPLY [Bug 52779] New: mod_lua segfaults
https://issues.apache.org/bugzilla/show_bug.cgi?id=52779
Bug #: 52779
Summary: mod_lua segfaults
Product: Apache httpd-2
Version: 2.4.1
Platform: PC
OS/Version: Linux
Status: NEW
Severity: major
Priority: P2
Component: mod_lua
AssignedTo: bugs@httpd.apache.org
ReportedBy: marco@tols.org
Classification: Unclassified
Created attachment 28390
--> https://issues.apache.org/bugzilla/attachment.cgi?id=28390
crude fix for the segfaults - doesn't consider whether it opens memleaks
Hi there,
I mailed this to the users@httpd.apache.org mailing list with subject "mod_lua
segfault in httpd-2.4.1" last friday, but this is probably a better place to
report it.
Also, I checked whether the fix for bug 49044 also fixes this issue, but it
doesn't. Also the memset(0) that is used in the fix for that bug is now solved
by using apr_pcalloc instead of apr_palloc in the code from the 2.4.1 tarball,
so doesn't apply anymore.
What I mailed is this:
------
Goodday,
I have tried to make a setup using mod_lua using version 2.4.1 of the
apache httpd server and noticed that requests involving lua render a
segfault message in the error log like this one:
---
[Fri Feb 24 11:42:41.410706 2012] [core:notice] [pid 64609:tid 34397516800]
AH00052: child pid 64612 exit signal Segmentation fault (11)
---
This is very easy to replicate by following these steps:
- download the httpd-2.4.1.tar.gz from
http://httpd.apache.org/download.cgi#apache24
- create a directory, in my case I created /apache24 and changed
ownership to myself
- extract the tarball
- execute:
./configure --prefix /apache24 --enable-lua
- run 'make' and 'make install'
- modify /apache24/conf/httpd.conf and make the following changes:
Listen 8080 # (Instead of 80)
LoadModule lua_module modules/mod_lua.so
LuaHookAccessChecker /apache24/lua/luatest.lua access_hook
- Create /apache24/lua/luatest.lua with the following contents (Other
contents render a segfault as well)
-----
require 'apache2'
function access_hook(r)
r:puts("---- access_hook\n")
return apache2.DECLINE
end
-----
- start the server using a simple '/apache24/bin/httpd'
- Keep a tail open on the error log
- Do something like: curl -D - -s 'http://localhost:8080/'
- You will see expected output, i.e. "---- access_hook" and the "It
works!" text.
- The error log will log a segfault from the child that handled the
request, like the one I paste above.
This can be fixed by the attached patch, which is really crude and
doesn't consider whether it opens up a memory leak or not.
Is there something I'm doing wrong, or is this a bug in the 2.4.1
mod_lua?
This happens both on FreeBSD 9.0-RELEASE as well as
linux 2.6.27.59 and 3.0.20.
Thanks in advance,
Marco van Tol
------
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 52779] mod_lua segfaults
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52779
--- Comment #5 from Marco van Tol <ma...@tols.org> ---
Hm, I had replied a couple of days ago, but that somehow didn't make it into
this system. What I wrote was this, which is still valid:
-----
As far as I'm concerned Dick Snippe became authoritative for this bug.
Without going into much out-of-scope detail, he continued where I left off. :-)
Thank you,
-----
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 52779] mod_lua segfaults
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52779
Stefan Fritsch <sf...@sfritsch.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |FixedInTrunk
--- Comment #4 from Stefan Fritsch <sf...@sfritsch.de> ---
committed to trunk as r1351012
Marco, can you verify if that fixes the problem for you, too?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 52779] mod_lua segfaults
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52779
Rainer Jung <ra...@kippdata.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Rainer Jung <ra...@kippdata.de> ---
Allied to 2.4 as part of r1369494.
Released with 2.4.3.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 52779] mod_lua segfaults
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52779
Marco van Tol <ma...@tols.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|marco@tols.org |
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 52779] mod_lua segfaults
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52779
Wietse Muizelaar <wi...@omroep.nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wietse.muizelaar@omroep.nl
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 52779] mod_lua segfaults
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52779
--- Comment #2 from Dick Snippe <Di...@tech.omroep.nl> ---
Because
static apr_status_t vm_construct(void **vm, void *params, apr_pool_t
*lifecycle_pool)
does a *vm = L and thereby dereferences a void pointer. When I change it to
static apr_status_t vm_construct(lua_State **vm, void *params, apr_pool_t
*lifecycle_pool)
the function acts as expected and the problem appers to be solved
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
DO NOT REPLY [Bug 52779] mod_lua segfaults
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52779
Marco van Tol <ma...@tols.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marco@tols.org
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 52779] mod_lua segfaults
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52779
--- Comment #1 from Dick Snippe <Di...@tech.omroep.nl> ---
I just replicated this bug.
The segfault is caused by cleanup_lua getting passed a NULL pointer;
this NULL pointer is passed to lua_close(NULL), which tries to dereference
is which cases a segfault.
So how can cleanup_lua be passed a NULL pointer? Here is where it gets weird:
The NULL pointer stems from ap_lua_get_lua_state where apr_pool_userdata_set
is called with L==NULL.
Now the weird thing is that L appears to be filled in slightly later.
I added some debug code to print the value of L returned by vm_construct
if(L==NULL) {
ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, lifecycle_pool,
APLOGNO(01483)
"creating lua_State with file %s", spec->file);
/* not available, so create */
if(vm_construct((void **)&L, spec, lifecycle_pool) == APR_SUCCESS) {
ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, lifecycle_pool,
APLOGNO(01483)
"call apr_pool_userdata_set with %x", (unsigned int) L);
ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, lifecycle_pool,
APLOGNO(01483)
"call apr_pool_userdata_set with %x", (unsigned int) L);
apr_pool_userdata_set(L,
spec->file,
cleanup_lua,
lifecycle_pool);
}
note that both ap_log_perror calls are identical, however the output isn't
identical:
[Tue Jun 12 22:00:10.169038 2012] [lua:debug] [pid 25340:tid 1136863568]
lua_vmprep.c(415): AH01483: creating lua_State with file
/home/beheer/dick/apache/lua/luatest.lua
[Tue Jun 12 22:00:10.169696 2012] [lua:debug] [pid 25340:tid 1136863568]
lua_vmprep.c(365): AH01481: loading lua file
/home/beheer/dick/apache/lua/luatest.lua
[Tue Jun 12 22:00:10.169905 2012] [lua:debug] [pid 25340:tid 1136863568]
lua_vmprep.c(420): AH01483: call apr_pool_userdata_set with 0
[Tue Jun 12 22:00:10.169924 2012] [lua:debug] [pid 25340:tid 1136863568]
lua_vmprep.c(423): AH01483: call apr_pool_userdata_set with 2224bc0
I assume that without the debug code the first (NULL) value is passed
to apr_pool_userdata_set, causing havoc.
As to why L==NULL at the firs reference but not on subsequent references I have
no idea. A bad compiler optimization perhaps?
That might explain why not everybody can replicate this bug.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org
[Bug 52779] mod_lua segfaults
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52779
Dick Snippe <Di...@tech.omroep.nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #28390|0 |1
is obsolete| |
--- Comment #3 from Dick Snippe <Di...@tech.omroep.nl> ---
Created attachment 28926
--> https://issues.apache.org/bugzilla/attachment.cgi?id=28926&action=edit
change void** to lua_State ** to wokr around compiler(?) issue
This simple patch changes the type of the first argument in vm_construct from
void ** to lua_State **, this fixes our issue on 64bit linux, gcc 4.1.2.
the issue does not happen on 32bit linux.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org