Have you tried the poor man’s binary error checker?
Delete half the file and see if the problem goes away. If it does you know the problem is in that half. If it doesn’t, try the other half. If it still doesn’t go away delete everythign in the file. If the problem is still there you’re looking in the wrong file.
Then just keep cutting the code in half untill you isolate your bug.