我的应用场景是这样的,在使用企业微信会话归档服务时,对方未提供php版本的SDK,只提供了JAVA和C++版本的SDK,所以想到编写一个PHP扩展来调用他们的C++版本的SDK,扩展调用是这样做的:在config.m4文件中使用PHP_ADD_INCLUDE,PHP_ADD_LIBRARY_WITH_PATH加载的第三方的.so文件,然后在PHP_RINIT_FUNCTION中调用了第三方.so文件的方法,插件可以正常编译,但是当加载插件后,运行PHP提示:
free(): invalid pointer
Aborted (core dumped)
GDB查看了下堆栈,看不太懂:
(gdb) r
Starting program: /usr/bin/php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
free(): invalid pointer
Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007ffff5e658b1 in __GI_abort () at abort.c:79
#2 0x00007ffff5eae907 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff5fdbdfa "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3 0x00007ffff5eb597a in malloc_printerr (str=str@entry=0x7ffff5fd9fe8 "free(): invalid pointer") at malloc.c:5350
#4 0x00007ffff5ebce8c in _int_free (have_lock=0, p=0x7fffe72ca5f0, av=0x7ffff6210c40 ) at malloc.c:4157
#5 __GI___libc_free (mem=0x7fffe72ca600 ) at malloc.c:3124
#6 0x00007fffe6f186a2 in std::locale::_Impl::_M_install_facet (this=0x7fffe72ca780 , __idp=, __fp=0x7fffe72ca250 )
at ../../../.././libstdc++-v3/src/c++98/locale.cc:352
#7 0x00007fffe6f18b03 in std::locale::_Impl::_M_init_facet<:numpunct> > (__facet=0x7fffe72ca250 , this=0x7fffe72ca780 )
at /home/ramonzhu/3rdcode/gcc-4.9.3/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/locale_classes.h:564
#8 std::locale::_Impl::_Impl (this=0x7fffe72ca780 , __refs=) at ../../../.././libstdc++-v3/src/c++98/locale_init.cc:402
#9 0x00007fffe6f19a75 in std::locale::_S_initialize_once () at ../../../.././libstdc++-v3/src/c++98/locale_init.cc:267
#10 0x00007ffff5c15827 in __pthread_once_slow (once_control=0x7fffe72c91f8 <:locale::_s_once>, init_routine=0x7fffe6f19a60 <:locale::_s_initialize_once>) at pthread_once.c:116
#11 0x00007fffe6f19ac1 in __gthread_once (__func=0x7fffe6f19a60 <:locale::_s_initialize_once>, __once=)
at /home/ramonzhu/3rdcode/gcc-4.9.3/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu/bits/gthr-default.h:699
#12 std::locale::_S_initialize () at ../../../.././libstdc++-v3/src/c++98/locale_init.cc:276
#13 0x00007fffe6f19b03 in std::locale::locale (this=0x7fffe72cb278 <:buf_cout_sync>) at ../../../.././libstdc++-v3/src/c++98/locale_init.cc:210
#14 0x00007fffe6f16e54 in std::basic_streambuf >::basic_streambuf (this=) at /home/ramonzhu/3rdcode/gcc-4.9.3/x86_64-unknown-linux-gnu/libstdc++-v3/include/streambuf:466
#15 __gnu_cxx::stdio_sync_filebuf >::stdio_sync_filebuf (__f=0x7ffff6211760 <_io_2_1_stdout_>, this=)
at /home/ramonzhu/3rdcode/gcc-4.9.3/x86_64-unknown-linux-gnu/libstdc++-v3/include/ext/stdio_sync_filebuf.h:77
#16 std::ios_base::Init::Init (this=) at ../../../.././libstdc++-v3/src/c++98/ios_init.cc:85
#17 0x00007fffe6f09814 in __static_initialization_and_destruction_0 (__initialize_p=, __priority=-15264) at /usr/include/c++/4.1.2/iostream:76
#18 0x00007fffe6f70a16 in __do_global_ctors_aux () from /root/packages/sdk_20200401/C_sdk/libWeWorkFinanceSdk_C.so
#19 0x00007fffe6c67648 in _init () from /root/packages/sdk_20200401/C_sdk/libWeWorkFinanceSdk_C.so
#20 0xfffffffffffffb78 in ?? ()
#21 0x00007ffff7de573c in call_init (env=0x555555c2ee70, argv=0x7fffffffe598, argc=1, l=0x555555cf7660) at dl-init.c:58
#22 _dl_init (main_map=main_map@entry=0x555555cf7080, argc=1, argv=0x7fffffffe598, env=0x555555c2ee70) at dl-init.c:119
#23 0x00007ffff7dea24f in dl_open_worker (a=a@entry=0x7fffffffcc50) at dl-open.c:522
#24 0x00007ffff5f8c51f in __GI__dl_catch_exception (exception=0x7fffffffcc30, operate=0x7ffff7de9e10 , args=0x7fffffffcc50) at dl-error-skeleton.c:196
#25 0x00007ffff7de981a in _dl_open (file=0x7ffff3209000 "/usr/lib/php/20170718/wxwork_finance_sdk.so", mode=-2147483383, caller_dlopen=0x555555726973 , nsid=, argc=1, argv=,
env=0x555555c2ee70) at dl-open.c:605
#26 0x00007ffff6f80f96 in dlopen_doit (a=a@entry=0x7fffffffce80) at dlopen.c:66
#27 0x00007ffff5f8c51f in __GI__dl_catch_exception (exception=exception@entry=0x7fffffffce20, operate=0x7ffff6f80f40 , args=0x7fffffffce80) at dl-error-skeleton.c:196
#28 0x00007ffff5f8c5af in __GI__dl_catch_error (objname=0x555555c88f40, errstring=0x555555c88f48, mallocedp=0x555555c88f38, operate=, args=) at dl-error-skeleton.c:215
#29 0x00007ffff6f81745 in _dlerror_run (operate=operate@entry=0x7ffff6f80f40 , args=args@entry=0x7fffffffce80) at dlerror.c:162
#30 0x00007ffff6f81051 in __dlopen (file=, mode=) at dlopen.c:87
#31 0x0000555555726973 in php_load_shlib ()
#32 0x0000555555726b77 in php_load_extension ()
#33 0x00005555557e968e in zend_llist_apply ()
#34 0x000055555579a45a in ?? ()
#35 0x000055555579281e in php_module_startup ()
#36 0x00005555558aa20d in ?? ()
#37 0x000055555564050e in ?? ()
#38 0x00007ffff5e46b97 in __libc_start_main (main=0x555555640240, argc=1, argv=0x7fffffffe598, init=, fini=, rtld_fini=, stack_end=0x7fffffffe588) at ../csu/libc-start.c:310
#39 0x00005555556407fa in _start ()
(gdb)
但是另外一台服务器可以正常调用,请问老师这个可能是那方便除了问题?