-
Strange behaviours
Hello,
I have developed a program which has a function name 'cargarDLL' that inside it load a DLL made by an external developer (I mean, I have no control over dll source code).
My program and the DLL has been running OK until I upgrade compiler versión from 4.5.2 to 4.7.0. Now the first-called exported dll function runs ok, but when I return from my funcion (cargarDLL), in the 'return' keyword it crashes.
My question are:
* Does a DLL run in the data space of the called process? I ask this to know if a bug in the dll can corrupt my program. If not I am sure it is a bug in my code.
* If it is a bug in my code, how can I catch it? Because in the 'return' keyword I not see anything special to make me suspect of a bug.
Any ideas how can I solve this?
Thanks.
-
Sounds more like the code is crashing because of some other reason, not the DLL at all.
How do you catch it? <sarcasm mode> Have you tried using a debugger at all?</sarcasm mode>
Single-step the program with NO compiler optimisations and see what happens. Chances are you will discover that it crashes somewhere else entirely.
Also, if you want a "quick and dirty" test, just splat the function with printf's and other code in between calling the DLL and returning and outside the function from it's original call-point (which is where I'd focus my debug efforts, to be honest - sounds like you return a value that causes whatever code that called "cargarDLL" to crash). See what return values you are getting, what you're returning, what you're passing off to the DLL, etc. Call the function outside of everything else in your code (i.e. as close to being the first line of main() as you can get) with valid values and see what it does.
At a complete guess, I'd say you're returning something like a memory handle to local memory, or the code calling cargarDLL just isn't setup to handle whatever it returns
But you would be saved from a lot of my and your own guesses by just using a debugger. That's what they are there for. Hell, they're even pretty good at telling you if something crashes in a DLL you loaded, or even things like the C runtime and not your code.