- 论坛徽章:
- 0
|
在linux下利用调用Mysql的C API时,总是出现段错误,请问大家是怎么回事?调用mysql_query,mysql_real_escape_string等函数时都会产生段错误。
例如:
sprintf(tmp,"delete from table where pathname = '%s'",pathname) ;
mysql_query(conn, tmp);
在执行mysql_query就会发生段错误,使用catchsegv捕获得到如下信息:
Backtrace:
/lib/libSegFault.so[0xfe539f]
/lib/tls/libpthread.so.0[0xdd09c8]
/usr/lib/libmysqlclient.so.15(mysql_send_query+0xbc)[0x176b07]
/usr/lib/libmysqlclient.so.15(mysql_real_query+0x2c)[0x176b35]
/usr/lib/libmysqlclient.so.15(mysql_query+0x3a)[0x14cef2]
/home/duck/ftp_server/my_sql.c:85(delete_info_from_mysql)[0x804a07d] ;调用mysql_query()
/home/duck/ftp_server/delete_c.c:15(delete_c)[0x8049c5e]
/home/duck/ftp_server/MyMain.c:75(main)[0x804923c]
/lib/tls/libc.so.6(__libc_start_main+0xd3)[0xb9fde3]
??:0(_start)[0x8048ead]
Memory map:
00111000-001db000 r-xp 00000000 fd:00 729346 /usr/lib/libmysqlclient.so.15.0.0
001db000-002ea000 rw-p 000c9000 fd:00 729346 /usr/lib/libmysqlclient.so.15.0.0
002ea000-002eb000 rw-p 002ea000 00:00 0
002eb000-002f4000 r-xp 00000000 fd:00 848764 /lib/libgcc_s-3.4.6-20060404.so.1
002f4000-002f5000 rw-p 00009000 fd:00 848764 /lib/libgcc_s-3.4.6-20060404.so.1
00796000-0079f000 r-xp 00000000 fd:00 848690 /lib/libnss_files-2.3.4.so
0079f000-007a0000 r--p 00008000 fd:00 848690 /lib/libnss_files-2.3.4.so
007a0000-007a1000 rw-p 00009000 fd:00 848690 /lib/libnss_files-2.3.4.so
008d4000-008d9000 r-xp 00000000 fd:00 849997 /lib/libcrypt-2.3.4.so
008d9000-008da000 r--p 00004000 fd:00 849997 /lib/libcrypt-2.3.4.so
008da000-008db000 rw-p 00005000 fd:00 849997 /lib/libcrypt-2.3.4.so
008db000-00902000 rw-p 008db000 00:00 0
00b71000-00b87000 r-xp 00000000 fd:00 848708 /lib/ld-2.3.4.so
00b87000-00b88000 r--p 00015000 fd:00 848708 /lib/ld-2.3.4.so
00b88000-00b89000 rw-p 00016000 fd:00 848708 /lib/ld-2.3.4.so
00b8b000-00cb1000 r-xp 00000000 fd:00 848736 /lib/tls/libc-2.3.4.so
00cb1000-00cb3000 r--p 00125000 fd:00 848736 /lib/tls/libc-2.3.4.so
00cb3000-00cb5000 rw-p 00127000 fd:00 848736 /lib/tls/libc-2.3.4.so
00cb5000-00cb7000 rw-p 00cb5000 00:00 0
00cb9000-00cda000 r-xp 00000000 fd:00 848741 /lib/tls/libm-2.3.4.so
00cda000-00cdb000 r--p 00020000 fd:00 848741 /lib/tls/libm-2.3.4.so
00cdb000-00cdc000 rw-p 00021000 fd:00 848741 /lib/tls/libm-2.3.4.so
00dc5000-00dd3000 r-xp 00000000 fd:00 848763 /lib/tls/libpthread-2.3.4.so
00dd3000-00dd4000 r--p 0000d000 fd:00 848763 /lib/tls/libpthread-2.3.4.so
00dd4000-00dd5000 rw-p 0000e000 fd:00 848763 /lib/tls/libpthread-2.3.4.so
00dd5000-00dd7000 rw-p 00dd5000 00:00 0
00de9000-00df8000 r-xp 00000000 fd:00 723143 /usr/lib/libz.so.1.2.1.2
00df8000-00df9000 rw-p 0000e000 fd:00 723143 /usr/lib/libz.so.1.2.1.2
00fe4000-00fe7000 r-xp 00000000 fd:00 848661 /lib/libSegFault.so
00fe7000-00fe8000 r--p 00002000 fd:00 848661 /lib/libSegFault.so
00fe8000-00fe9000 rw-p 00003000 fd:00 848661 /lib/libSegFault.so
0528f000-052a1000 r-xp 00000000 fd:00 848792 /lib/libnsl-2.3.4.so
052a1000-052a2000 r--p 00011000 fd:00 848792 /lib/libnsl-2.3.4.so
052a2000-052a3000 rw-p 00012000 fd:00 848792 /lib/libnsl-2.3.4.so
052a3000-052a5000 rw-p 052a3000 00:00 0
08048000-0804b000 r-xp 00000000 fd:00 201929 /home/duck/ftp_server/myftp
0804b000-0804c000 rw-p 00002000 fd:00 201929 /home/duck/ftp_server/myftp
08e5a000-08e7f000 rw-p 08e5a000 00:00 0
b7fbd000-b7fc0000 rw-p b7fbd000 00:00 0
b7fd8000-b7fd9000 rw-p b7fd8000 00:00 0
bfdb3000-c0000000 rw-p bfdb3000 00:00 0
ffffe000-fffff000 ---p 00000000 00:00 0
请大家帮忙分析下是怎么回事
[ 本帖最后由 canjian 于 2008-10-5 22:27 编辑 ] |
|