I'm making a program to work with very large integers. The numbers are stored as a dynamic array of bytes. The arithmetic operations I've implemented involve a lot of brute force, and a lot of temporary arrays which are soon deleted.
Everything works fine for low numbers, but for larger numbers like 25^400, I start getting segmentation faults at strange places. After many repetitions of the same code, a segmentation fault suddenly occurs when I delete a temporary array. The fault doesn't occur for smaller numbers, and it doesn't occur every time that particular array is deleted. If I comment out that delete line, a segmentation fault now occurs at another line, now on a 'new' allocation.
The code is long and boring, but I could post some if anyone really wants. Does anyone have any general advice about segmentation faults and how to find their cause?