If someone has the time, would you be able to check out the following
scenario for me. It causes a segfault in Apache 2.0.51 on Mac OS X with
mod_python 3.2.5b.

What I am playing with is connection handlers. Specifically, I have a code
file containing:

  from mod_python import apache

  def connectionhandler(conn):
    apache.log_error("connectionhandler")
    try:
      while 1:
        #conn.write(conn.readline())
        conn.write(conn.read())
    except IOError:
      pass
    return apache.OK

If I enable this connection handler for the default listener port for Apache,
ie., simply add in main Apache config:

  PythonPath '["/Users/grahamd/Sites/add_handler"]+sys.path'
  PythonConnectionHandler example::connectionhandler

The connection handler works and is equivalent to mod_echo.

If however I enable the connection handler on a secondary port,
a bus error occurs when read() or readline() is called by the connection
handler. Ie.,

  Listen 8081

  PythonPath '["/Users/grahamd/Sites/add_handler"]+sys.path'

  <VirtualHost *:8081>
  PythonConnectionHandler example::connectionhandler
  </VirtualHost>

get bus error and gdb gives the output at end of email. Note that if
the connection handler simply returns apache.DECLINED, everything
is okay and Apache will serve up pages fine, only when doing read
of data from connection handler does it decide to crash.

(gdb) cont
Continuing.

Program received signal EXC_BAD_ACCESS, Could not access memory.
[Switching to process 2342 thread 0xc03]
0x00000058 in ?? ()
(gdb) where
#0  0x00000058 in ?? ()
Cannot access memory at address 0x58
Cannot access memory at address 0x58
#1  0x006068f8 in _conn_read (c=0x1933014, mode=AP_MODE_READBYTES, len=0) at 
connobject.c:117
#2  0x00606b04 in conn_read (self=0x471da0, args=0xf0101140) at connobject.c:177
#3  0x95fa94a8 in PyEval_GetFuncDesc ()
#4  0x95fa6c64 in PyEval_EvalCode ()
#5  0x95fa9728 in PyEval_GetFuncDesc ()
#6  0x95fa9580 in PyEval_GetFuncDesc ()
#7  0x95fa6c64 in PyEval_EvalCode ()
#8  0x95fa9728 in PyEval_GetFuncDesc ()
#9  0x95fa9580 in PyEval_GetFuncDesc ()
#10 0x95fa6c64 in PyEval_EvalCode ()
#11 0x95fa7e30 in PyEval_EvalCodeEx ()
#12 0x95fa97dc in PyEval_GetFuncDesc ()
#13 0x95fa9580 in PyEval_GetFuncDesc ()
#14 0x95fa6c64 in PyEval_EvalCode ()
#15 0x95fa7e30 in PyEval_EvalCodeEx ()
#16 0x95f5f354 in PyFunction_SetClosure ()
#17 0x95f4a8d0 in PyObject_Call ()
#18 0x95f529e8 in PyMethod_New ()
#19 0x95f4a8d0 in PyObject_Call ()
#20 0x95f4ab7c in PyObject_CallMethod ()
#21 0x0060eab0 in python_connection (con=0x192c540) at mod_python.c:1313
#22 0x0003fce4 in ap_run_process_connection (c=0x192c540) at connection.c:42
#23 0x0002395c in process_socket (p=0x186e598, sock=0x507f20, 
my_child_num=-267382460, my_thread_num=0, bucket_alloc=0x192c540) at 
worker.c:520
#24 0x000240bc in worker_thread (thd=0x460e30, dummy=0xf0101140) at worker.c:834
#25 0x9499d990 in _pthread_body ()
(gdb) 

If someone is at least able to confirm this, will log a bug report, but since
I doubt anyone is using connection handlers in mod_python, no point
trying to fix it quickly if it is a problem in mod_python. For example, maybe
it is setting up wrong bucket brigade for virtual host.

Graham

Reply via email to