Forum > General
How to find out why the compiler hangs ?
Nitorami:
Today I encountered an issue I never had before. Normally my program compiles within two seconds, then I made a small modification to the Class hierarchy in a bottom unit, and when I now try to build, the compiler keeps hanging in an endless loop, after having compiled all except the topmost unit. It says "Compiling - press ESC to cancel", but does not react to ESC nor anything else. Processor load is at 60% permanently.
I reverted the code change and it compiles, I can live with that, that is not the issue. But this should be reported, only, I cannot possibly submit the entire program for diagnosis.
Have tried many other compiler settings, target processors etc. but to no avail. Tried changing from objfpc to delphi mode; well, the compiler then does not hang but throws a lot of error messages because my code is not delphi compatible. Have deleted the old .o and .ppu files, and the fp.ini, fp.dsk, fp.cfg, but nothing helps. I shuffled the order of units in the "uses" section but no sucess either.
How can I narrow down such a problem ? Each time I try a new compilation with modified settings or whatever, I'll have to kill the IDE and start a new command processor. Getting tired of that.
I am using the textmode IDE with FPC3.0.2 and win32. Don't think anything is wrong with my installation, as only this specific code change causes the problem. Will try FPC 3.0.4 next but am not too optimistic.
Leledumbo:
That's one kind of hard to reproduce problem. The compiler might be trapped in an infinite loop somehow (well, it's not in anyway magical). Still, a small source that can reproduce the behavior is expected. If it's hard to write one, then I guess you can help by debugging the compiler yourself, using your project source code. There's a .lpi in the compiler source directory, you can use that for debugging the compiler in lazarus. Maybe it will help if you at least mention what changes to the source code trigger this behavior so a compiler dev can point where to put breakpoint closer to the problem source.
molly:
As TS is not using lazarus and the problem seems related to text mode ide (internal compiler) TS could perhaps try to compile sources using only the commandline compiler. IF you do not have it it would be a separate installation.
That would be able to better pinpoint if it is compiler or (only) textmode related.
@Nitorami, be aware that compiling generics can take a (very) long while. for instance compiling the delphi generics collection took ages, and it gets worse when there is something actually wrong in the code. But seeing that when you revert it compiles fine, would probably indicate something else is amiss.
Something that is able to tell you where things go wrong is using verbose all option, but i take it that this only points to compiling the unit that contains the problematic code. if not, then please dump that log for us to see. Perhaps the compiler gets stuck somewhere else.
Other than that: make a copy of your current code and then start chopping away to see if you are able to reproduce with a smaller example code.
Nitorami:
Yes, certainly the compiler is trapped in an endless loop. I don't use generics so that cannot be the reason for long compilation times.
The verbose option seemed like a good idea but as the compiler hangs, the messages are lost :D But when I compile the units individually, the messages do not seem to indicate anything unusual.
Another funny thing is, if I insert a typo at the end of the main program, the compiler complains, but when I correct it and recompile, it hangs. The issue may be close to the linker stage.
The textmode IDE displays a compiler progress window, informing about the currently compiled unit and line number. I hoped that this might be useful, but the text is different on each try. I guess the window content is only loosely synchronised to the compilation process.
Recompiling and debugging the sources is somewhat beyond my skills I fear. I'll try the "chopping" approach and see whether I can reproduce the issue with much less code.
Leledumbo:
--- Quote from: Nitorami on January 09, 2018, 10:01:23 pm ---Another funny thing is, if I insert a typo at the end of the main program, the compiler complains, but when I correct it and recompile, it hangs. The issue may be close to the linker stage.
--- End quote ---
I'm not too sure about it, if you make a typo that would be on parsing stage. But if the source is syntactically valid, the infinite loop can be anywhere inside the compiler (sub)processes. Also, did you use any options related to code generation (e.g. -O, -Oo, -Op, -Cp, -Cf)?
Navigation
[0] Message Index
[#] Next page