Stick at it. Its just one of those things Ive found sometimes happen.
I will be interested to hear other peoples suggestions though.
I do it by putting in printf's or diag_var's from the start of the function,
with one before and after every 'significant' line or if-block.
If the printf you just inserted makes the crashes stop, then remove one of the
previous ones and the crash will usually return.
If it doesnt, then move it down line-by-line until the crash returns, or you
get data out of the printf that tells you what has gone wrong.
My usual problem is with badly-sized Malloc blocks.
I love making them one byte too small for some reason....
Best of luck