There is a PHP program. The command line execution is as follows:
[Root @ h10-vm08 demo] # PHP parsefile. php XXXX. ykml
* ** Glibc detected ** free (): Invalid Pointer: 0xb7869b7c ***
Aborted
[Root @ h10-vm08 demo] #
The so file of PHP extension called by this PHP program has an invalid access pointer error, but where does the error occur? It is most convenient to use GDB to locate such problems.
[Root @ h10-vm08 demo] # GDB PHP
(GDB) Run parsefile. php XXXX. ykml
Starting program:/home/y/bin/PHP parsefile. php XXXX. ykml
[Thread Debugging Using libthread_db enabled]
[New thread-1208723776 (lwp 3225)]
* ** Glibc detected ** free (): Invalid Pointer: 0xb783cbc4 ***
Program received signal SIGABRT, aborted.
[Switching to thread-1208723776 (lwp 3225)]
0x005847a2 in _ dl_sysinfo_int80 () from/lib/ld-linux.so.2
(GDB)
(GDB) BT
#0 0x005847a2 in _ dl_sysinfo_int80 () from/lib/ld-linux.so.2
#1 0x004477a5 in raise () from/lib/tls/libc. so.6
#2 0x00449209 in abort () from/lib/tls/libc. so.6
#3 0x0047b71a in _ libc_message () from/lib/tls/libc. so.6
#4 0x00481fbf in _ int_free () from/lib/tls/libc. so.6
#5 0x0048233a in free () from/lib/tls/libc. so.6
#6 0x02f37b56 in fbmlstylesheet: translateurl () from/home/y/lib/PHP/20060613/fbml. So
#7 0x02f0000a5 in cssparserimpl: parseurl () from/home/y/lib/PHP/20060613/fbml. So
#8 0x02f44585 in cssparserimpl: parsevariant () from/home/y/lib/PHP/20060613/fbml. So
#9 0x02f461c0 in cssparserimpl: parsesinglevalueproperty () from/home/y/lib/PHP/20060613/fbml. So
......
In this way, the stack trajectory is obtained and the function with an error is located.
Breakpoint:
(GDB) B 'cssparserimpl: parseurl (unsigned Int &, nscssvalue &)'
This function stops running the program.