I'm writing an ext for Apples OpenDirectory (directory services) API and it
makes heavy use of registering resources in the zend internal list. I'm also
new to the Zend API.
As of now I have about 4 resource types so far. In Short, my resource life
span goes like:
- zend_register_list_destructors_ex(... for each resource in
ZEND_MINIT_FUNCTION() - register a resource and return it, RETURN_RESOURCE(zend_list_insert(rsrc,
le_rsrc)); - upon user destruction function, zend_list_delete(Z_LVAL_P(z_rsrc));
- resource destructor is called when deleted from the internal list, frees
all assoc memory allocated/closes any connections then uses efree to free up
memory alloced to the resource with emalloc.
My problem is, all my resources get deleted from the list and my destructors
are called an exit properly but at the end of my php script, while testing,
I get a bus error on the very last line. The backtrace boils down to
shutdown_memory_manager. My thoughts are that I must have something wrong in
the destruction of resources, does anyone know what would cause the bus
error in shutdown_memory_manager? A backtrace is below, I can also provide
more detailed code snippets.
$ php -v
PHP 4.3.0 (cli) (built: Dec 27 2002 20:26:15)
Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies
$ tail ~/Library/Logs/CrashReporter/php.crash.log
Date/Time: 2003-08-11 09:25:46 -0400
OS Version: 10.2.5 (Build 6L29)
Host: 128kb.com
Command: php
PID: 12508
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000000
Thread 0 Crashed:
#0 0x0018aeb0 in shutdown_memory_manager
#1 0x0015e354 in php_request_shutdown
#2 0x001c25c0 in main
#3 0x00001d24 in _start
#4 0x00001b54 in start
PPC Thread State:
srr0: 0x0018aeb0 srr1: 0x0200f030 vrsave: 0x00000000
xer: 0x00000000 lr: 0x0018aee0 ctr: 0x90003da0 mq: 0x00000000
r0: 0x008a931b r1: 0xbfffdf50 r2: 0x00000000 r3: 0x005bf010
r4: 0x008b43a0 r5: 0x0000000c r6: 0x002c6100 r7: 0x00000000
r8: 0x005bf010 r9: 0x00000000 r10: 0x00000002 r11: 0x008b43a0
r12: 0x90003da0 r13: 0x00000000 r14: 0x00000000 r15: 0x00000000
r16: 0x00000000 r17: 0x00000000 r18: 0x00000000 r19: 0x00000000
r20: 0x00000000 r21: 0x00000000 r22: 0x00000000 r23: 0x00000000
r24: 0x00000000 r25: 0x00000000 r26: 0xbffff968 r27: 0x00000010
r28: 0x00000003 r29: 0xbffff97c r30: 0xbfffdf50 r31: 0x0018ade8
--
Justin Hannus
Can't you get a line number and the actual address being accessed to cause
that crash?
I'm writing an ext for Apples OpenDirectory (directory services) API and it
makes heavy use of registering resources in the zend internal list. I'm also
new to the Zend API.As of now I have about 4 resource types so far. In Short, my resource life
span goes like:
- zend_register_list_destructors_ex(... for each resource in
ZEND_MINIT_FUNCTION()- register a resource and return it, RETURN_RESOURCE(zend_list_insert(rsrc,
le_rsrc));- upon user destruction function, zend_list_delete(Z_LVAL_P(z_rsrc));
- resource destructor is called when deleted from the internal list, frees
all assoc memory allocated/closes any connections then uses efree to free up
memory alloced to the resource with emalloc.My problem is, all my resources get deleted from the list and my destructors
are called an exit properly but at the end of my php script, while testing,
I get a bus error on the very last line. The backtrace boils down to
shutdown_memory_manager. My thoughts are that I must have something wrong in
the destruction of resources, does anyone know what would cause the bus
error in shutdown_memory_manager? A backtrace is below, I can also provide
more detailed code snippets.$ php -v
PHP 4.3.0 (cli) (built: Dec 27 2002 20:26:15)
Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies
$ tail ~/Library/Logs/CrashReporter/php.crash.log
Date/Time: 2003-08-11 09:25:46 -0400
OS Version: 10.2.5 (Build 6L29)
Host: 128kb.comCommand: php
PID: 12508Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000000Thread 0 Crashed:
#0 0x0018aeb0 in shutdown_memory_manager
#1 0x0015e354 in php_request_shutdown
#2 0x001c25c0 in main
#3 0x00001d24 in _start
#4 0x00001b54 in startPPC Thread State:
srr0: 0x0018aeb0 srr1: 0x0200f030 vrsave: 0x00000000
xer: 0x00000000 lr: 0x0018aee0 ctr: 0x90003da0 mq: 0x00000000
r0: 0x008a931b r1: 0xbfffdf50 r2: 0x00000000 r3: 0x005bf010
r4: 0x008b43a0 r5: 0x0000000c r6: 0x002c6100 r7: 0x00000000
r8: 0x005bf010 r9: 0x00000000 r10: 0x00000002 r11: 0x008b43a0
r12: 0x90003da0 r13: 0x00000000 r14: 0x00000000 r15: 0x00000000
r16: 0x00000000 r17: 0x00000000 r18: 0x00000000 r19: 0x00000000
r20: 0x00000000 r21: 0x00000000 r22: 0x00000000 r23: 0x00000000
r24: 0x00000000 r25: 0x00000000 r26: 0xbffff968 r27: 0x00000010
r28: 0x00000003 r29: 0xbffff97c r30: 0xbfffdf50 r31: 0x0018ade8--
Justin Hannus
"Rasmus Lerdorf" rasmus@lerdorf.com wrote in message
news:Pine.LNX.4.56.0308110753160.31632@thinkpad.lerdorf.com...
Can't you get a line number and the actual address being accessed to cause
that crash?
Sorry about that, I'll have to recompile a version with --enable-debug which
I might not get a chance to until later tonight.
-Justin Hannus
"Rasmus Lerdorf" rasmus@lerdorf.com wrote in message
news:Pine.LNX.4.56.0308110753160.31632@thinkpad.lerdorf.com...
Can't you get a line number and the actual address being accessed to cause
that crash?
Here is a more detailed backtrace. In my original post I was using php-4.3.0
but the recompiled version with --enable-debug I'm using php-4.3.2 built
with cli sapi.
Program received signal EXC_BAD_ACCESS, Could not access memory.
0x90000f00 in strlen ()
(gdb) bt
#0 0x90000f00 in strlen ()
#1 0x000ff800 in format_converter (odp=0xbfffd630, fmt=0x18726d "s(%d)
: Freeing 0x%.8lX (%d bytes), script=%s\n", ap=0xbfffd6e8 "") at
/Users/m31/Documents/downloads/php-4.3.2/main/snprintf.c:720
#2 0x000ffea8 in strx_printv (ccp=0xbfffd6a0, buf=0xbfffd700 "",
len=512, format=0x18726c "%s(%d) : Freeing 0x%.8lX (%d bytes),
script=%s\n", ap=0xbfffd6e4 "") at
/Users/m31/Documents/downloads/php-4.3.2/main/snprintf.c:908
#3 0x000fff58 in ap_php_snprintf (buf=0xbfffd700 "", len=512,
format=0x18726c "%s(%d) : Freeing 0x%.8lX (%d bytes), script=%s\n") at
/Users/m31/Documents/downloads/php-4.3.2/main/snprintf.c:922
#4 0x000fb0d0 in php_message_handler_for_zend (message=4,
data=0x503030) at
/Users/m31/Documents/downloads/php-4.3.2/main/main.c:816
#5 0x0014a2a4 in zend_message_dispatcher (message=4, data=0x503030) at
/Users/m31/Documents/downloads/php-4.3.2/Zend/zend.c:665
#6 0x0012f174 in shutdown_memory_manager (silent=0, clean_cache=0) at
/Users/m31/Documents/downloads/php-4.3.2/Zend/zend_alloc.c:510
#7 0x000fb960 in php_request_shutdown (dummy=0x0) at
/Users/m31/Documents/downloads/php-4.3.2/main/main.c:992
#8 0x0016b4e4 in main (argc=3, argv=0xbffff82c) at
/Users/m31/Documents/downloads/php-4.3.2/sapi/cgi/cgi_main.c:1555
#9 0x00002734 in _start (argc=3, argv=0xbffff82c, envp=0xbffff83c) at
/SourceCache/Csu/Csu-45/crt.c:267
#10 0x000025b4 in start ()
"Rasmus Lerdorf" rasmus@lerdorf.com wrote in message
news:Pine.LNX.4.56.0308110753160.31632@thinkpad.lerdorf.com...Can't you get a line number and the actual address being accessed to cause
that crash?Here is a more detailed backtrace. In my original post I was using php-4.3.0
but the recompiled version with --enable-debug I'm using php-4.3.2 built
with cli sapi.
do you use any shared php extensions by any chance?
thies
Program received signal EXC_BAD_ACCESS, Could not access memory.
0x90000f00 in strlen ()
(gdb) bt
#0 0x90000f00 in strlen ()
#1 0x000ff800 in format_converter (odp=0xbfffd630, fmt=0x18726d "s(%d)
: Freeing 0x%.8lX (%d bytes), script=%s\n", ap=0xbfffd6e8 "") at
/Users/m31/Documents/downloads/php-4.3.2/main/snprintf.c:720
#2 0x000ffea8 in strx_printv (ccp=0xbfffd6a0, buf=0xbfffd700 "",
len=512, format=0x18726c "%s(%d) : Freeing 0x%.8lX (%d bytes),
script=%s\n", ap=0xbfffd6e4 "") at
/Users/m31/Documents/downloads/php-4.3.2/main/snprintf.c:908
#3 0x000fff58 in ap_php_snprintf (buf=0xbfffd700 "", len=512,
format=0x18726c "%s(%d) : Freeing 0x%.8lX (%d bytes), script=%s\n") at
/Users/m31/Documents/downloads/php-4.3.2/main/snprintf.c:922
#4 0x000fb0d0 in php_message_handler_for_zend (message=4,
data=0x503030) at
/Users/m31/Documents/downloads/php-4.3.2/main/main.c:816
#5 0x0014a2a4 in zend_message_dispatcher (message=4, data=0x503030) at
/Users/m31/Documents/downloads/php-4.3.2/Zend/zend.c:665
#6 0x0012f174 in shutdown_memory_manager (silent=0, clean_cache=0) at
/Users/m31/Documents/downloads/php-4.3.2/Zend/zend_alloc.c:510
#7 0x000fb960 in php_request_shutdown (dummy=0x0) at
/Users/m31/Documents/downloads/php-4.3.2/main/main.c:992
#8 0x0016b4e4 in main (argc=3, argv=0xbffff82c) at
/Users/m31/Documents/downloads/php-4.3.2/sapi/cgi/cgi_main.c:1555
#9 0x00002734 in _start (argc=3, argv=0xbffff82c, envp=0xbffff83c) at
/SourceCache/Csu/Csu-45/crt.c:267
#10 0x000025b4 in start ()--
--
Thies C. Arntzen - Looking for all sorts of freelance work - just ask..
http://www.amazon.de/exec/obidos/wishlist/AB9DY62QWDSZ
do you use any shared php extensions by any chance?
Yes, I'm developing an extension to wrap Apple's OpenDirectory API (reffer
to my first post). Thats the only shared extension that I'm using.
do you use any shared php extensions by any chance?Yes, I'm developing an extension to wrap Apple's OpenDirectory API (reffer
to my first post). Thats the only shared extension that I'm using.
if you have a mem-leak in your extension it will be printed
at script-shutdown, but as your extension has already been
unloaded by the engine this will segfault.
so - just try to build your extension static into php, debug
it and build it shared once you have no leaks left....
re,
tc
--
Thies C. Arntzen - Looking for all sorts of freelance work - just ask..
http://www.amazon.de/exec/obidos/wishlist/AB9DY62QWDSZ
> it and build it shared once you have no leaks left....
>
Thanks, I'll try that.
-Justin Hannus