I've experienced something slightly diffirent but involving multy threading.
The only way to reslove problems like these is to establish where the occur. It's a tedious process, and especially when you get them in release versions only.
What you need to do is create a log file and put marker event(printf "I'm here" etc ) in you appllication in every function and first determine at what function block the failure occured and then add entries in the function block and determine what specific function call fails.
Then once you know more about your problem you will be closer to a solution and you migh be able to ask a more specific question.
Normlly works for me.
Jattie van der Linde
Engineering Manager, Software & Automation
TEL Magnetic Solutions Ltd