Problem with DB handles
I'm using couple of Sybase stored procedure calls from my C program. If I comment any one of the SP call, the code works fine but if both the calls are made then the code core dumps.
Will this may be a problem with db handles? I even tried using two different handles for the SP calls. Even then it core dumped. :mad:
Could you please tell me wht might be the problem? and how to solve it ?
Thanks in advance,
Does it still core dump if you comment out most of your other code so it just calls these two procedures and very little else?
No I cant do that. It a pretty big code (1000 LOCs)..the SP depends on other variables so it can't be done..
any other idea??
Look at the side effects of the Sybase call. Is there a contextual structure that is being changed as a result of the first call that must be reinitialized before the second call? A good place to start looking is at any structure that you pass to the Sybase calls that is shared between the two calls. Also look at any structures returned by the Sybase interface library.
I don't have enough information to point you at anything specific.
- Compile the code with debug enabled.
- Run the program inside the debugger.
The debugger should catch the segfault, and provide you with a stack backtrace of the function call heirarchy at the point of the fault.
If malloc or free are in that list (which is a fairly common reason), then check all your usage of malloc and free to make sure you're not overstepping the end of allocated memory, using it after free, freeing twice, freeing what wasn't malloced etc etc.
You might also try say electric fence (if you have that)
gcc prog.c -lefence
And run that in the debugger as well. If you have a malloc overrun problem for example, that should trap the point where it happens (as opposed to the more normal case of noticing somethings wrong later on).