View Single Post
  #1   (View Single Post)  
Old 9th June 2008
gor gor is offline
New User
 
Join Date: Jun 2008
Posts: 3
Default MySQL C library - segmentation fault on mysql_select_db() when using CC optimisation

Hello,

I have segmentation fault while trying to execute a binary that uses MySQL C API. An error occurs every time mysql_select_db() is called. The output says:
Code:
in free(): error: free_pages: pointer to wrong page
Abort trap (core dumped)
After hours of debugging, i've discovered that -O compiler flag causes that error to come. If compiled without -O flag - everything works like a charm. e.g. (compiler options from Makefile):
Code:
COPT=-I /usr/local/include/mysql -L /usr/local/lib/mysql -O
Binary crashes with segfault

Code:
COPT=-I /usr/local/include/mysql -L /usr/local/lib/mysql
Binary works fine

I am not sure whether the problem is caused by MySQL C API bug or error in cc (or maybe error in programmer )

The OS is OpenBSD 4.2 GENERIC.MP amd64

Thank you for suggestions.
Regards.
Reply With Quote