Bug #42166 mysql_real_connect() Unhandled exception/Access violation at 0x00000000
Submitted: 16 Jan 2009 16:51 Modified: 16 Feb 2009 17:25
Reporter: Miguel Cardenas Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:6.0.8 OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any
Tags: 2008, C++, debug, express, mysql_real_connect, visual

[16 Jan 2009 16:51] Miguel Cardenas
Description:
General information:
- Windows XP (running in VirtualBox 2.1.0)
- MySQL 6.0.8 windows binary with installer (setup.exe)
- Visual C++ 2008 express
- My software is built in C++ and uses MySQL C API

Failure:
mysql_real_connect() causes "Unhandled exception at 0xXXXXXXXX in MYPROGRAM.exe: 0xC0000005: Access violation reading 0x00000000" when running in debug session (only). Running "Start without debugging" WORKS PERFECT.

Technical notes:
My code compiles and runs in Linux, FreeBSD and Solaris with no problems, even in Windows works but when executed inside the VC++ 2008 express debugger it aborts no matter it runs freely or step-by-step. The execution appears to stop in a strlen() call inside create_shared_memory() that is called by mysql_real_connect() according the call stack. The problem arises with both MySQL debug and opt libraries. My project setup is based on this post http://forums.mysql.com/read.php?45,49606,49606#msg-49606 but adapted to VC++ 2008

CALL STACK
------------------------------------------
libv2.dll!strlen(unsigned char * buf=0x10233738)  Line 81	Asm
----------
libv2.dll!create_shared_memory(st_mysql * mysql=0x003a49f8, st_net * net=0x003a49f8, unsigned int connect_timeout=0)  Line 487 + 0x15 bytes	C
----------
libv2.dll!mysql_real_connect(st_mysql * mysql=0x003a49f8, const char * host=0x0012fee4, const char * user=0x0012fe5c, const char * passwd=0x0012fdd4, const char * db=0x00000000, unsigned int port=0, const char * unix_socket=0x00000000, unsigned long client_flag=0)  Line 1901 + 0x1a bytes	C
------------------------------------------

Extra notes: this program in particular calls my MySQL functions inside my library libv2.dll that has a class to encapsulate a single connection BUT it happens the same even in a simple plain C/C++ independent test program where it calls directly mysql_real_connect()/mysql_close() it aborts at same point.

How to repeat:
It always aborts at the same point when running inside the VC++ 2008 express debugger, no special conditions. I reinstalled all system/software 3 times so it is not a damaged system.

Running directly from command line, file manager or inside VC++ without debugging works 100% normal.
[16 Jan 2009 16:59] MySQL Verification Team
Thank you for the bug report. Why you think is the C API bug and not VS2008 bug? are you tried to debug using for example WinDBG?. Thanks in advance.
[16 Jan 2009 17:15] Miguel Cardenas
Hi

I will try with WinDBG to confirm or discard the possibility that it is MySQL. Don't know WinDBG (am *NIX developer) but will search for it and upgrade this report.

I have posted at MySQL mailing list (there got the suggestion to submit the "bug") but got no solution, at VirtualBox to ask if it could cause the create_shared_memory() failure and the MSDN VC++ forum where they said it is my program because thinking it is MySQL is a big assumption and VC++ is okay.

In the case that my program runs fine with WinDBG will go back to MSDN and append a note/comment to this bug report clearing it is a VC++ bug and not MySQL.

Thanks for your help
[16 Jan 2009 17:25] MySQL Verification Team
Thank you for the feedback. Reopen this bug report when you have additional info anyway in case you still believe is a C API bug you need to provide a C/C++ code test case. Thanks in advance.
[17 Feb 2009 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".