Topic: SIGSEGV - segmentation fault, only when debugging
My problems tend to be very strange ones, and I have another that again fits this description.
I have a large project, which compiles, links and runs perfectly well, without runtime error and with correct output results.
The executable runs without error, right through to completion.
There is some functionality I'd like to improve, however, which I can't seem to make work.
This, however, is NOT the problem.
The problem is that, whenever I try to use the debugger on the fully-working program, just in order to follow the program execution through and try to see what I need to modify in order to improve its functionality, the debugger crashes the unmodified version of my seemingly-correct program. As a result, I am unable to use the debugger as a software development tool.
The crash emits this error message:
Debugger Error
Signal received SIGSEGV - Segmentation fault
I have discovered that the program runs without a debugger error if I insert a breakpoint immediately before a particular DISLIN call. It is the DISLIN instruction,
CALL DWGfil('Structure DATA filename',F%Path,'*.*').
This instruction causes - or should cause - DISLIN to display a file-selection dialog box and to return the pathname of the file selected by the program user. There appears to be nothing wrong with either DISLIN or the way I have used it because, as I say, when I run my program without using the debugger, it works without crashing and without any ereror of any kind. It makes no difference whether I run it from withing Simply Fortran or by executing the executable as a free-standing Windows program. It works correctly in both cases. I have also had Helmut Michels (DISLIN author) and a colleague of Helmut's, both very kindly check DISLIN's use of this routine, and they both say it has no error.
A further clue, though not one which has helped me find a solution, is that, when the debugger crashes with a SIGSEGV fault, it appears to do so part-way through executing DISLIN's call to its DWGfil routine. That is to say, the crash occurs after drawing the entire dialog box and after just starting to populate it with the filenames list in the current directory. It manages to write-into the dialog box just the first filename, then freezes on the SIGSEGV error.
An even further clue is that I have occasionally managed to paste fast enough into the dialog box the name of the file to open, before the crash occurs. When I've managed this, the SIGSEGV crash does not occur straight away, but the program execution then gets a bit further, before finally crashing in the same way, with a SIGSEGV error.
Jeff, or anyone else, if you have any ideas, I'd greatly appreciate any help to get me through this.
I'm in the Catch-22 situation that I can't use the debugger to find the cause of teh problem because the program only crashes when I run it under the debugger.
---
John