sparkfizt
10-24-2008, 12:12 PM
I know we've got atleast a few professional programmers around here and so I've got a wierd bug I've fought for the last few days that I dont fully understand.
The setup is this:
I've got a C++ dll/so that is meant to be called in order to do some scientific calculations.
I've got a C driver application that is meant to flex and test the dll/so.
When I compile in windows it all functions as I expect, runs to completion and gives me the correct answer.
I then compile that same code through GCC for osx/unix. The driver application is a litttle different because unix shared object library syntax.
When I go to execute the application on osx it proceeds to crash(segfault). After digging at the program for a while became obvious it's due to the heap somehow becoming corrupted.
I cant post the source but I'll give you some pseudo-code.
Doing things in this order causes the crash:
load .so
create .so function pointers
call initialize on the .so returning a linked list
malloc a struct to be handed to the .so
while(not correct answer)
keep calling .so
However when I move the malloc to before instantiating the dll the program functions as it does on windows. This seems to indicate that malloc is stepping on the heap being used by the dll.
Anyone familiar with this kind of issue? Unfortunately most my experience lies with java and this bug has me scratching my head since to me it all seems semantically correct(but obviously I'm wrong somewhere).
The setup is this:
I've got a C++ dll/so that is meant to be called in order to do some scientific calculations.
I've got a C driver application that is meant to flex and test the dll/so.
When I compile in windows it all functions as I expect, runs to completion and gives me the correct answer.
I then compile that same code through GCC for osx/unix. The driver application is a litttle different because unix shared object library syntax.
When I go to execute the application on osx it proceeds to crash(segfault). After digging at the program for a while became obvious it's due to the heap somehow becoming corrupted.
I cant post the source but I'll give you some pseudo-code.
Doing things in this order causes the crash:
load .so
create .so function pointers
call initialize on the .so returning a linked list
malloc a struct to be handed to the .so
while(not correct answer)
keep calling .so
However when I move the malloc to before instantiating the dll the program functions as it does on windows. This seems to indicate that malloc is stepping on the heap being used by the dll.
Anyone familiar with this kind of issue? Unfortunately most my experience lies with java and this bug has me scratching my head since to me it all seems semantically correct(but obviously I'm wrong somewhere).