D
Dev
I'm working with some IBM sponsored C APIs to interface with a
corporate legacy system, and it seems that I'm getting some stack
corruption after any API call.
I believe the APIs were designed to be used with IBM VisualAge, but I'm
compiling my program with both gcc/cygwin and Microsoft's Visual C++
compiler. While running I actually get different behavior with each
compiler. To link to the library with cl.exe I generated a .lib file
from the .dll file using a small open source application (script) which
I can't seem to find online anymore (google reindex?).
I can get the program to continue to run for a while by adding a char
x[10000]; buffer as the last local variable in my function, but
eventually I get a core dump. Stepping through the application in gdb
I see my char buffer x go from '\0' (repeats 9999 times) to garbage
values after any IBM API call. Commenting out x yields an immediate
crash at best, or overwrites other necessary local variables which
wreaks bloody havoc on subsequent calls.
I've checked and double checked the parameters going into and coming
out of the API calls, and they appear to be correct. I've also
initialized all local variables.
I highly doubt that the IBM API is at fault, and I'm running out of
ideas to test my code. Is it possible that it's in how I compile my
code and link to the DLL? This is running as JNI code for a larger
Java application, so I'm using ANT to build (the behavior still
exhibits itself when all JNI code is removed and the program is run as
a c console application). Below are my build targets.
Does anyone have any further suggestions for debugging a gcc compiled
application linked to a proprietary dll in Windows? Is there any way
to get an easy printout of the stack at any given point in time?
Unfortunately, I do not own my code, so code samples can't be posted.
Just imagine horribly named API methods that take pointers to pointers
to deeply nested structs of pointers. =)
All help is greatly appreciated. My coworkers and I are starting to
bang our heads against the wall.
Thanks,
Dev
ANT targets:
<target name="compile-cl">
<exec dir="src" executable="cl.exe">
<arg line="-WX" />
<arg line="-Iinclude" />
<arg line="myApplication.c"/>
<arg line="-FeMyApplication" />
<arg line="C:Generated/API/Library/File.lib" />
</exec>
</target>
<target name="compile-gcc">
<exec dir="src" executable="gcc.exe">
<arg line="-Wall -g" />
<arg line="-mno-cygwin" />
<arg line="-Iinclude" />
<arg line="-Wl,\provided\library\file.dll" />
<arg line="-Wl,--add-stdcall-alias" />
<arg line="-o MyApplication"/>
<arg line="MyApplication.c" />
</exec>
</target>
corporate legacy system, and it seems that I'm getting some stack
corruption after any API call.
I believe the APIs were designed to be used with IBM VisualAge, but I'm
compiling my program with both gcc/cygwin and Microsoft's Visual C++
compiler. While running I actually get different behavior with each
compiler. To link to the library with cl.exe I generated a .lib file
from the .dll file using a small open source application (script) which
I can't seem to find online anymore (google reindex?).
I can get the program to continue to run for a while by adding a char
x[10000]; buffer as the last local variable in my function, but
eventually I get a core dump. Stepping through the application in gdb
I see my char buffer x go from '\0' (repeats 9999 times) to garbage
values after any IBM API call. Commenting out x yields an immediate
crash at best, or overwrites other necessary local variables which
wreaks bloody havoc on subsequent calls.
I've checked and double checked the parameters going into and coming
out of the API calls, and they appear to be correct. I've also
initialized all local variables.
I highly doubt that the IBM API is at fault, and I'm running out of
ideas to test my code. Is it possible that it's in how I compile my
code and link to the DLL? This is running as JNI code for a larger
Java application, so I'm using ANT to build (the behavior still
exhibits itself when all JNI code is removed and the program is run as
a c console application). Below are my build targets.
Does anyone have any further suggestions for debugging a gcc compiled
application linked to a proprietary dll in Windows? Is there any way
to get an easy printout of the stack at any given point in time?
Unfortunately, I do not own my code, so code samples can't be posted.
Just imagine horribly named API methods that take pointers to pointers
to deeply nested structs of pointers. =)
All help is greatly appreciated. My coworkers and I are starting to
bang our heads against the wall.
Thanks,
Dev
ANT targets:
<target name="compile-cl">
<exec dir="src" executable="cl.exe">
<arg line="-WX" />
<arg line="-Iinclude" />
<arg line="myApplication.c"/>
<arg line="-FeMyApplication" />
<arg line="C:Generated/API/Library/File.lib" />
</exec>
</target>
<target name="compile-gcc">
<exec dir="src" executable="gcc.exe">
<arg line="-Wall -g" />
<arg line="-mno-cygwin" />
<arg line="-Iinclude" />
<arg line="-Wl,\provided\library\file.dll" />
<arg line="-Wl,--add-stdcall-alias" />
<arg line="-o MyApplication"/>
<arg line="MyApplication.c" />
</exec>
</target>