Microsoft Interview Question
Software Engineer / Developersdouble deletion of pointers. Once a pointer is deleted the memory is freed and the program can allocate the freed memory to some body else.. this happens in multiple threads case where you might end up deleting a ptr in two different threads and depending on whom the address pointed to by this deleted ptr got allocated the crash might show up in different places..
Some reasons for crashing in different place each time:
(some overlap, some are similar, there could be plenty more)
1) it uses random numbers.
2) it uses time.
3) it persists state and reads it back the next time.
4) it could be eating up memory. Depending on other processes in the OS, it could get out of memory exceptions at different times.
5) the application is trying to mess with the OS (like trying to set the pagefile size) (the C standard library restriction might remove this cause, though)
6) it is trying to read/write to hardware device. (again, not sure what C library gives).
7) it is using shared memory.
if the source is given, why not show it here? It would be easier :-)
Possible problem: Memory overwrite.
- Jack of all October 12, 2007Use memory profiling tool to find it, like insure++ or purify etc