Summary: | mysql_init leads to segment fault | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Wallance <halyx> |
Component: | Current packages | Assignee: | Gentoo Linux bug wranglers <bug-wranglers> |
Status: | RESOLVED INVALID | ||
Severity: | normal | CC: | hydrapolic |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | AMD64 | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
mysql test program
core dump file for gdb debug emerge --info |
Created attachment 413754 [details]
core dump file for gdb debug
Created attachment 413758 [details]
emerge --info
I compiled maraidb with client-lib use flag and others are default. Please compile the test program as following: gcc mysql_test.cpp -o test `mysql_config --cflags` `mysql_config --libs` Hello, according to the manual: https://mariadb.com/kb/en/mariadb/mysql_init/ MYSQL * mysql_init(MYSQL * mysql); mysql - a pointer to MYSQL or NULL. In case of passing a NULL pointer mysql_init() will allocate memory and return a pointer to a MYSQL structure. In your code: MYSQL *mysql_conn; mysql_init(mysql_conn); It means you are passing a pointer, but it has no allocated memory. Try passing a NULL pointer so it will return a pointer for you that will have the memory allocated. Maybe go over a tutorial, something like: http://zetcode.com/db/mysqlc/ Good luck! |
Created attachment 413752 [details] mysql test program Hello,I use dev-db/mariadb-10.1.7_rc and glibc-2.21.Whenever I call mysql_init(MYSQL*) in my C Language program.It calls for memset and segment fault. I saved the core dump and backtrace as following. gdb ./test core.26412 Core was generated by `./test'. Program terminated with signal SIGSEGV, Segmentation fault. #0 __memset_sse2 () at ../sysdeps/x86_64/memset.S:78 78 movdqu %xmm8, (%rdi) (gdb) backtrace #0 __memset_sse2 () at ../sysdeps/x86_64/memset.S:78 #1 0x00007f2ce2ebb7d3 in mysql_init (mysql=0x4008b0 <_start>) at /usr/src/debug/dev-db/mariadb-10.1.7_rc/mysql/sql-common/client.c:1785 #2 0x00000000004009ba in main () at mysql_test.cpp:10 I can upload my test program too.