mod_lua segfault in httpd-2.4.1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


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
- 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/
  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
- 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

This happens both on FreeBSD 9.0-RELEASE as well as
linux and 3.0.20.

Thanks in advance,

Marco van Tol

Marco van Tol
diff -Nur httpd-2.4.1/modules/lua/lua_vmprep.c
---    2011-12-05 01:08:01.000000000 +0100
+++ httpd-2.4.1/modules/lua/lua_vmprep.c        2012-01-26 21:54:07.000000000 +0100
@@ -240,7 +240,7 @@
 /* callback for cleaning up a lua vm when pool is closed */
 static apr_status_t cleanup_lua(void *l)
-    lua_close((lua_State *) l);
+    if (l) lua_close((lua_State *) l);
     return APR_SUCCESS;

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx

[Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Photo]     [Yosemite Photos]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

Add to Google Powered by Linux