Using C API with MySQL 2nd query passed causes seg fault [solved]
I am attempting to interface with MySQL using the C API on an AMD64 machine. I am having problems with a segmentation fault after the first query is executed and results are returned.
Executing the queries 'directly' in MySQL is sucessful so I'm sure that I'm doing something totally, absolutely wrong with my code. I have Googled and studied code at codase.com but am not seeing what my code is missing. If anyone could point me in the right direction, I would appreciate it. Thanks in advance. MySQL version 5.0.33 was built with the following options passed to the configure script: --enable-thread-safe-client --enable-assembler --enable-local-infile --without-debug --without-bench --without-readline --with-extra-charsets=all --with-embedded-server Below are some snippets of my code to accompany this brief description of the program I am attempting to get working. The first snippet is the function that connects to the database. The connection is successful. Function 'initialize_system_tree' creates a GTK TreeView, then calls the function 'populate_system_tree' (the second snippet below). The 'initialize_function_tree' function creates a second GTK TreeView, then calls the function 'populate_function_tree'. The seg fault occurs when attempting to execute the mysql_real_query. Code:
void Code:
void Code:
void Code:
#0 0x00002b291be6db4c in mysql_send_query (mysql=0x5096f8, |
Are you sure you don't use any pointers to the result in your structures? It seems you're building something of the data.
|
Thanks for the tip, that got me looking in the right places.
I was using a structure as a "buffer" for the MySQL results. It was overlapping with the MySQL return structure resulting in weird data being passed to glibc functions. Don't really know why I was using the structure to "buffer" my results except I think structures are cool. In any event, populating the treeview directly with the results returned from the MySQL query eliminates the problem. |
All times are GMT -5. The time now is 11:29 AM. |