Release <-> Debug woes
-
Hi I have the following problem: I have an executable that loads dlls (MFC extension dll´s). All the dll´s are based on a parent class with various functions. To name a few BOOL mfb_open_database (LPCTSTR); CString mfx_get_module_name(); CString mfx_get_item_text (LPVOID); The functions are called from the main application using a pointer to the dll class.. x_txt = px_dll->mfx_get_item_text((LPVOID)something); The functions in the dll´s are all with AFX_MANAGE_STATE(..) because I´m loading things from the (DLL´s) resources The funny thing is only the mfx_get_module_name() does not work, all the others do. Tracing through this (I have added the debug symbols to the release mode of a dll and the exe) It comes about when the constructors for the CString objects are called. As far as I can tell, the DLL creates a CString object to be returned. Instead of a "Deep" copy, only the reference of it´s m_pchData is copied to the CString Object in the exe, and when the destructor for the CString Object in the exe is called, the MFC crashes and says that the Object that is to be destroyed is not in the "correct" heap. I have tried adding ::LockBuffer() to the CString object that is created in the DLL as the returned object but to no avail. I have checked all the project settings etc. and can´t find anything wrong. This function worked perfectly well up until yesterday, until my devstudio crashed a few times. I´ve checked all the settings in Project setings but can´t find anything un toward. Has anybody any idea´s I´m at my wits end.... Thanks in advance Phil bum... and I thought I´d got rid of all the bugs :(
-
Hi I have the following problem: I have an executable that loads dlls (MFC extension dll´s). All the dll´s are based on a parent class with various functions. To name a few BOOL mfb_open_database (LPCTSTR); CString mfx_get_module_name(); CString mfx_get_item_text (LPVOID); The functions are called from the main application using a pointer to the dll class.. x_txt = px_dll->mfx_get_item_text((LPVOID)something); The functions in the dll´s are all with AFX_MANAGE_STATE(..) because I´m loading things from the (DLL´s) resources The funny thing is only the mfx_get_module_name() does not work, all the others do. Tracing through this (I have added the debug symbols to the release mode of a dll and the exe) It comes about when the constructors for the CString objects are called. As far as I can tell, the DLL creates a CString object to be returned. Instead of a "Deep" copy, only the reference of it´s m_pchData is copied to the CString Object in the exe, and when the destructor for the CString Object in the exe is called, the MFC crashes and says that the Object that is to be destroyed is not in the "correct" heap. I have tried adding ::LockBuffer() to the CString object that is created in the DLL as the returned object but to no avail. I have checked all the project settings etc. and can´t find anything wrong. This function worked perfectly well up until yesterday, until my devstudio crashed a few times. I´ve checked all the settings in Project setings but can´t find anything un toward. Has anybody any idea´s I´m at my wits end.... Thanks in advance Phil bum... and I thought I´d got rid of all the bugs :(
-
are the dlls AND the app the same build type?? Release or Debug? I spent some days on a realy anoying bug. My App was Release Build and the DLL was Debugbuild and it crashes all the time!! solution-> use the same build type.
Yes, same build type. The really stupid thing is, that before the DevStudio crash everything worked fine :confused: bum... and I thought I´d got rid of all the bugs :(
-
Yes, same build type. The really stupid thing is, that before the DevStudio crash everything worked fine :confused: bum... and I thought I´d got rid of all the bugs :(
-
sure? I also thought all the time, my DLLs and the App are the same build, BUT somewhere deep was a silly path to the wrong directory with the wrong DLLs. :( don't know other reason.. sory.
Yes I´ve checked.. I´ll have another look at the settings in a text editor, but in the IDE everything seems to be ok. And thanks for helping... Phil bum... and I thought I´d got rid of all the bugs :(
-
Hi I have the following problem: I have an executable that loads dlls (MFC extension dll´s). All the dll´s are based on a parent class with various functions. To name a few BOOL mfb_open_database (LPCTSTR); CString mfx_get_module_name(); CString mfx_get_item_text (LPVOID); The functions are called from the main application using a pointer to the dll class.. x_txt = px_dll->mfx_get_item_text((LPVOID)something); The functions in the dll´s are all with AFX_MANAGE_STATE(..) because I´m loading things from the (DLL´s) resources The funny thing is only the mfx_get_module_name() does not work, all the others do. Tracing through this (I have added the debug symbols to the release mode of a dll and the exe) It comes about when the constructors for the CString objects are called. As far as I can tell, the DLL creates a CString object to be returned. Instead of a "Deep" copy, only the reference of it´s m_pchData is copied to the CString Object in the exe, and when the destructor for the CString Object in the exe is called, the MFC crashes and says that the Object that is to be destroyed is not in the "correct" heap. I have tried adding ::LockBuffer() to the CString object that is created in the DLL as the returned object but to no avail. I have checked all the project settings etc. and can´t find anything wrong. This function worked perfectly well up until yesterday, until my devstudio crashed a few times. I´ve checked all the settings in Project setings but can´t find anything un toward. Has anybody any idea´s I´m at my wits end.... Thanks in advance Phil bum... and I thought I´d got rid of all the bugs :(
I have finally found the problem. In one of my base classes I have over written the OnDraw() and OnEraseBkgnd() to draw a custom background. Instead of using the MFC message entry macro, ON_WM_ERASEBKGND(), ON_WM_PAINT(), I used the API one: ON_MESSAGE(WM_PAINT, ...) etc. This all worked fine in debug mode, but crashed in release. Now everything works fine bum... and I thought I´d got rid of all the bugs :(