Subject: locking in getenv
To: None <current-users@netbsd.org>
From: Patrick Welche <prlw1@newn.cam.ac.uk>
List: current-users
Date: 01/31/2004 20:07:43
In apache, if I LoadModule the php5 module compiled with --enable-libxml, 
I get the following backtrace. If I disable libxml, all is OK. How
can this cause a core dump in getenv?!

#0  0x482949fb in kill () from /usr/lib/libc.so.12
#1  0x48296c6b in __libc_rwlock_catchall_stub (l=0x80d40a5)
    at /usr/src/lib/libc/thread-stub/thread-stub.c:239
#2  0x48307979 in getenv (name=0x80d40a5 "SHOW_HOOKS")
    at /usr/src/lib/libc/stdlib/getenv.c:66
#3  0x0809fb75 in ap_register_hooks (m=0x48457a40, p=0x80ec018) at config.c:433
#4  0x0809fd93 in ap_add_loaded_module (mod=0x48457a40, p=0x80ec018)
    at config.c:565
#5  0x0809d7cf in load_module (cmd=0xbfbff520, dummy=0x0,
    modname=0x8130cb8 "php5_module", filename=0x48457a40 "eĽ1\001\003")
    at mod_so.c:323
 
Presumably CHECK_NOT_THREADED(); is causing the abort...
 
getenv:
        rwlock_rdlock(&__environ_lock);
        result = __findenv(name, &offset);
        rwlock_unlock(&__environ_lock);
 
rwlock_rdlock, rwlock_unlock are all essentially just CHECK_NOT_THREADED,
i.e., if(__isthreaded)DIE();

In fact it works now as I recompiled libxml --without-threads. However,
I'm still confused: why is obtaining a lock the same as checking one
isn't in a thread? What might the underlying problem be? one in libxml,
or the way mod_php uses it?

Cheers,

Patrick