3,881
社区成员
发帖
与我相关
我的任务
分享insert data successfully
*** stack smashing detected ***: ./server terminated
Segmentation fault (core dumped)
int insert(MYSQL *conn_ptr, TRANFER_DATA data)
{
char sql[100];
memset(sql, 0, sizeof(sql));
sprintf(sql, "INSERT INTO USER_POSITION_INFO(telnum, imei, longitude, latitude, time) VALUES \
('%s', '%s', %f, %f, '%s')", data.telnum, data.imei, data.longitude, data.latitude, data.time);
if (mysql_query(conn_ptr, sql) != 0)
{
fprintf(stderr, "occur a errno: %s\n", mysql_error(conn_ptr));
return EXIT_FAILURE;
}
printf("insert data successfully\n");
return EXIT_SUCCESS;
}
gdb ./server core
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/freeman/Desktop/graduation project/Server/server...done.
[New LWP 6425]
[New LWP 6415]
warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7f4e1afa5000
Core was generated by `./server'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f4e19143066 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
(gdb) run ./server
Starting program: /home/freeman/Desktop/graduation project/Server/server ./server
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff6b9f700 (LWP 6488)]
[Thread 0x7ffff6b9f700 (LWP 6488) exited]
connection success!
server is running...
runa client connected...
[New Thread 0x7ffff6b9f700 (LWP 6489)]
insert data successfully
*** stack smashing detected ***: /home/freeman/Desktop/graduation project/Server/server terminated
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff6b9f700 (LWP 6489)]
0x00007ffff6198066 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
$ gdb -c core ./server
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/freeman/Desktop/graduation project/Server/server...done.
[New LWP 6425]
[New LWP 6415]
warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7f4e1afa5000
Core was generated by `./server'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f4e19143066 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
(gdb) where
#0 0x00007f4e19143066 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#1 0x00007f4e19143d7d in _Unwind_Backtrace () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#2 0x00007f4e1a58a108 in backtrace () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007f4e1a4f33af in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007f4e1a589f47 in __fortify_fail () from /lib/x86_64-linux-gnu/libc.so.6
#5 0x00007f4e1a589f10 in __stack_chk_fail () from /lib/x86_64-linux-gnu/libc.so.6
#6 0x000000000040196e in insert (conn_ptr=0x603140, data=...) at db_operator.c:49
#7 0x36352e373231202c in ?? ()
#8 0x3233202c33303034 in ?? ()
#9 0x2c3030303935312e in ?? ()
#10 0x302d343130322720 in ?? ()
#11 0x3a35312031302d34 in ?? ()
#12 0x00292733323a3432 in ?? ()
#13 0x4200a2d142ff20c5 in ?? ()
#14 0x2d34302d34313032 in ?? ()
#15 0x34323a3531203130 in ?? ()
#16 0x000000000033323a in ?? ()
#17 0x00007f4e1afa89d8 in _rtld_global () from /lib64/ld-linux-x86-64.so.2
#18 0xffffffffffffffff in ?? ()
#19 0x00007ffffb3fc074 in ?? ()
#20 0x0000000000000000 in ?? ()