Segmentation faults on exit after loading extension, functions unrecognized

From: Date: Fri, 03 Sep 2004 18:46:09 +0000
Subject: Segmentation faults on exit after loading extension, functions unrecognized
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-1259@lists.php.net to get a copy of this message
Hey folks, I'm having one heck of a problem. Background: * I have a C/C++ library, libxxx.so, that is currently being used by extensions for both Perl and Python (so I know it is a valid library and does not in itself die). * I have followed the tutorials available on the PECL site for use in PHP 4.3, specifically the one by J. Smith, and have `pear install package.xml` creating a PHP Extension (phpXXX.so) that does not give an error when loaded using dl(). * After using dl() to load my extension, the functions exported by it, processXXX and verifyXXX, are present in the array returned by get_defined_functions() * The compiled extension is using the same header file and library as the working Perl and Python versions, although more files have been added for PHP to call upon per the tutorial by J. Smith (and ext_skel) * In trying to get '-Xlinker -export-dynamic' into the compile options, I temporarily added it to the CC environment variable (I couldn' figure out what variable to set to get it added at the proper location, so I did it manually) Summary of Problem: After loading the extension, any attempt to access a function exported by the extension results in a "Fatal error: Call to undefined function: processXXX() ...". After loading the extension, at any point when the script completes (this is from the command-line, btw) a segmentation fault occurs. Thank you very much for any help, Andy Smith Files / Logs: I also have a basic Makefile.in, and php_phpXXX.h as described by the tutorial, and I believe I have set up the XXX.cpp properly. If, however, the information I have provided here so far does not provide enough information, I can include that file on request. valgrind yields a couple of seemingly interesting results, however I'm really no pro when it comes to debugging C: Program Started Loading library ==7115== ==7115== Conditional jump or move depends on uninitialised value(s) ==7115== at 0x400089E1: (within /lib/ld-2.3.3.so) ==7115== by 0x40CB00C3: (within /lib/libc-2.3.3.so) ==7115== by 0x4000A9F5: (within /lib/ld-2.3.3.so) ==7115== by 0x40CB03D6: _dl_open (in /lib/libc-2.3.3.so) ==7115== ==7115== Syscall param sigaction(act) contains uninitialised or unaddressable byte(s) ==7115== at 0x40BF71E8: __libc_sigaction (in /lib/libc-2.3.3.so) ==7115== by 0x432C1FCE: pthread_initialize (pthread.c:518) ==7115== by 0x4352DA44: (within /usr/local/lib/libxxx.so) ==7115== by 0x432B9B64: (within /usr/local/lib/libxxx.so) ==7115== Address 0xBFFFC5F4 is on thread 1's stack ==7115== ==7115== Syscall param sigaction(act) contains uninitialised or unaddressable byte(s) ==7115== at 0x40BF71E8: __libc_sigaction (in /lib/libc-2.3.3.so) ==7115== by 0x432C1FF0: pthread_initialize (pthread.c:521) ==7115== by 0x4352DA44: (within /usr/local/lib/libxxx.so) ==7115== by 0x432B9B64: (within /usr/local/lib/libxxx.so) ==7115== Address 0xBFFFC5F4 is on thread 1's stack ==7115== ==7115== Syscall param sigaction(act) contains uninitialised or unaddressable byte(s) ==7115== at 0x40BF71E8: __libc_sigaction (in /lib/libc-2.3.3.so) ==7115== by 0x432C2023: pthread_initialize (pthread.c:526) ==7115== by 0x4352DA44: (within /usr/local/lib/libxxx.so) ==7115== by 0x432B9B64: (within /usr/local/lib/libxxx.so) ==7115== Address 0xBFFFC5F4 is on thread 1's stack ==7115== ==7115== Conditional jump or move depends on uninitialised value(s) ==7115== at 0x40C34866: strstr (in /lib/libc-2.3.3.so) ==7115== by 0x432C20BF: pthread_initialize (smp.h:47) ==7115== by 0x4352DA44: (within /usr/local/lib/libxxx.so) ==7115== by 0x432B9B64: (within /usr/local/lib/libxxx.so) ==7115== ==7115== Conditional jump or move depends on uninitialised value(s) ==7115== at 0x40C3486E: strstr (in /lib/libc-2.3.3.so) ==7115== by 0x432C20BF: pthread_initialize (smp.h:47) ==7115== by 0x4352DA44: (within /usr/local/lib/libxxx.so) ==7115== by 0x432B9B64: (within /usr/local/lib/libxxx.so) lib loaded Loading file done. Fatal error: Call to undefined function: processxxx() in /home/andy/xxx/test.php on line 23 ==7115== ==7115== Conditional jump or move depends on uninitialised value(s) ==7115== at 0x822010E: zend_hash_apply_with_argument (in /usr/bin/php) ==7115== ==7115== Conditional jump or move depends on uninitialised value(s) ==7115== at 0x40BF997D: __cxa_finalize (in /lib/libc-2.3.3.so) ==7115== by 0x431744CF: (within /usr/lib/php/extensions/no-debug-non-zts-20020429/phpXXX.so) ==7115== by 0x431754D5: (within /usr/lib/php/extensions/no-debug-non-zts-20020429/phpXXX.so) ==7115== by 0x40CB0E75: _dl_close (in /lib/libc-2.3.3.so) ==7115== ==7115== Conditional jump or move depends on uninitialised value(s) ==7115== at 0x40BF997D: __cxa_finalize (in /lib/libc-2.3.3.so) ==7115== by 0x432BA81F: (within /usr/local/lib/libxxx.so) ==7115== by 0x4352E0AD: (within /usr/local/lib/libxxx.so) ==7115== by 0x40CB0E75: _dl_close (in /lib/libc-2.3.3.so) ==7115== valgrind's libpthread.so: KLUDGED call to: sem_destroy ==7115== ==7115== Conditional jump or move depends on uninitialised value(s) ==7115== at 0x40BF997D: __cxa_finalize (in /lib/libc-2.3.3.so) ==7115== by 0x43B22E8F: (within /lib/libutil-2.3.3.so) ==7115== by 0x43B23785: (within /lib/libutil-2.3.3.so) ==7115== by 0x40CB0E75: _dl_close (in /lib/libc-2.3.3.so) ==7115== discard syms in /usr/lib/php/extensions/no-debug-non-zts-20020429/phpXXX.so due to munmap() ==7115== discard syms in /usr/local/lib/libxxx.so due to munmap() ==7115== discard syms in /lib/libutil-2.3.3.so due to munmap() ==7115== ==7115== Conditional jump or move depends on uninitialised value(s) ==7115== at 0x40BF997D: __cxa_finalize (in /lib/libc-2.3.3.so) ==7115== by 0x4313947F: (within /usr/lib/php/extensions/no-debug-non-zts-20020429/java.so) ==7115== by 0x4313A9F5: (within /usr/lib/php/extensions/no-debug-non-zts-20020429/java.so) ==7115== by 0x40CB0E75: _dl_close (in /lib/libc-2.3.3.so) ==7115== discard syms in /usr/lib/php/extensions/no-debug-non-zts-20020429/java.so due to munmap() ==7115== ==7115== Jump to the invalid address stated on the next line ==7115== at 0x432C2670: ??? ==7115== by 0x8237FD7: main (in /usr/bin/php) ==7115== by 0x40BE38A7: __libc_start_main (in /lib/libc-2.3.3.so) ==7115== by 0x808EBE0: (within /usr/bin/php) ==7115== Address 0x432C2670 is not stack'd, malloc'd or free'd Segmentation fault The test.php script that generated this looked like, it never makes it to the last "Called": ======test.php: <? echo "Program Started\n"; if (!extension_loaded('phpXXX')) { $prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : ''; echo "Loading library\n"; if (!dl($prefix . 'phpXXX.' . PHP_SHLIB_SUFFIX)) { die("phpXXX module was not loaded by PHP\n"); } echo "lib loaded\n"; } $file1 = join("", file("file1")); echo "Loading file done.\n"; /* echo $file1."\n"; print_r(get_defined_functions()); */ $result = processXXX($file1); print "Called\n"; ?> ======config.m4: if test "$PHP_PHPXXX" != "no"; then PHP_REQUIRE_CXX() PHP_ADD_LIBRARY('nsl', , PHPXXX_SHARED_LIBADD) PHP_ADD_LIBRARY('dl', , PHPXXX_SHARED_LIBADD) PHP_ADD_LIBRARY('util', , PHPXXX_SHARED_LIBADD) PHP_ADD_LIBRARY('ieee', , PHPXXX_SHARED_LIBADD) PHP_ADD_LIBRARY('pthread', , PHPXXX_SHARED_LIBADD) PHP_ADD_LIBRARY('xxx', , PHPXXX_SHARED_LIBADD) PHP_NEW_EXTENSION(phpXXX, XXX.cpp, $ext_shared) PHP_SUBST(PHPXXX_SHARED_LIBADD) fi

« previous php.pecl.dev (#1259) next »