"Compilation raised exception internally" on recent 3.3.1 compiler builds lazarus / 62-General ---------------------------------------------------------------------- Paradice · 2024-05-19 12:45 All of the recent development builds of fpc 3.3.1 (up to and including the current build from May 20th 2024) have started throwing an unhandled exception error when compiling my largest project. Target and platform are both Win32/i386. Compiler builds compiled with FpcUpDeluxe. Not using Lazarus at all. I have a compiler from 3.3.1 dev branch version from Feb 27th 2024 which compiles everything successfully, but newer versions bug out. (not sure exactly what date it failed, I only rebuild FPC every month or so - it's been failing for the past ~3 months). With recent versions, using -B to build all sources will work as expected, but even immediately after that, attempting a simple recompile of any source file within the project without -B will trigger this error. Unfortunately, reducing it down to a "minimum source to reproduce the error" is tricky, I'm only experiencing this on my main project which is probably ~150 units of various interconnections. Which unit is the last unit "Compiling" before the exception varies, but it seems to always be 3 or 4 units after whatever I first attempt to compile. Any advice on what to look into? I'm not very experienced with git, hence using FPCUpDeluxe to compile FPC for me. --- Command line: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i E:\FPC\3.3.1\bin\i386-win32\fpc.exe @E:\Projects\.Meta\FPCsettings331.cfg -dDEBUG E:\Projects\Paradice500\Paradice500.pp---- Output: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Free Pascal Compiler version 3.3.1-15711-geff10ee9b7 [2024/05/20] for i386Copyright (c) 1993-2024 by Florian Klaempfl and othersTarget OS: Win32 for i386Compiling E:\Projects\Paradice500\Paradice500.ppCompiling E:\projects\lx7\lx7core.ppCompiling E:\projects\lx7\lx7debug.ppCompiling coreStrings.ppError: Compilation raised exception internallyFatal: Compilation abortedAn unhandled exception occurred at $00437B8A:EAccessViolation: Access violation  $00437B8A  $0056A0FD  $0056A74D  $0056AA9C  $0056A284  $0056A74D  $0056AA9C  $0056A0E4  $0056A74D  $0056AA9C  $0056A0E4  $0056A74D  $0056AA9C  $0056A0E4  $0056A74D  $0056AA9C  $005B4C37 ---------------------------------------------------------------------- jamie · 2024-05-19 13:59 I don't fully know the switches of the compiler, nor should there be an error like that, which of course is a reportable error. But, with Laz, I elect to use an external debug file so that it does not attach itself to the EXE., makes it much smaller. Maybe you are running out of space and the compiler is not catching it at the correct moment? ---------------------------------------------------------------------- Eugene Loza · 2024-05-19 16:52 Unfortunately things like that happen, and there isn't much you can do about that. If clean-up and build fixes the issue, then you might as well just create a script to delete all o and ppu files in the temporary output folder - this is slightly faster than recompiling the project and all dependencies. Cutting your project down to minimal reproducible example for a bugreport is almost the only way you can try dealing with the issue. Yes, it takes time (last bugreport took me >3 hours to cut from 40k lines down to 70). Making a bisection of FPC history to find a specific commit that started the bug also may help. Yes, eventually the result may be very delayed - as someone smart enough will need to investigate your bugreport and spend a ton of time understanding what is going wrong and how to fix it. There is also an option to rewrite/simplify the code, it seems like convoluted generic operations are very prone to confuse FPC. But for that you need to try to figure out what exactly goes wrong. It may help if you get a debug build of FPC, see attached image on how to do that in FPCUpDeluxe. ---------------------------------------------------------------------- Paradice · 2024-05-20 05:06 Thanks for your help, Eugene! - I've recompiled the compiler in debug mode to see if it gave me any clues... now I'm getting this output: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i E:\FPC\3.3.1\bin\i386-win32\fpc.exe @E:\Projects\.Meta\FPCsettings331.cfg -dRELEASE E:\Projects\Paradice500\Paradice500.ppCompiling Release VersionCompiling Release VersionHint: End of reading config file E:\Projects\.Meta\FPCsettings331.cfgFree Pascal Compiler version 3.3.1-15713-gcab3b8c06f [2024/05/20] for i386Copyright (c) 1993-2024 by Florian Klaempfl and othersTarget OS: Win32 for i386Compiling E:\Projects\Paradice500\Paradice500.ppCompiling E:\projects\lx7\lx7core.ppCompiling E:\projects\lx7\lx7events.ppCompiling coreStrings.ppError: Compilation raised exception internallyFatal: Compilation abortedAn unhandled exception occurred at $00438D2A:EAccessViolation: Access violation  $00438D2A  TMODULE__ADDDEPENDENCY,  line 1005 of fmodule.pas  $0056B2CD  TPPUMODULE__LOAD_USEDUNITS,  line 1958 of fppu.pas  $0056B91D  TPPUMODULE__TRY_LOAD_PPUFILE,  line 2221 of fppu.pas  $0056BC6C  TPPUMODULE__LOADPPU,  line 2362 of fppu.pas  $0056B454  TPPUMODULE__LOAD_USEDUNITS,  line 2014 of fppu.pas  $0056B91D  TPPUMODULE__TRY_LOAD_PPUFILE,  line 2221 of fppu.pas  $0056BC6C  TPPUMODULE__LOADPPU,  line 2362 of fppu.pas  $0056B2B4  TPPUMODULE__LOAD_USEDUNITS,  line 1953 of fppu.pas  $0056B91D  TPPUMODULE__TRY_LOAD_PPUFILE,  line 2221 of fppu.pas  $0056BC6C  TPPUMODULE__LOADPPU,  line 2362 of fppu.pas  $0056B2B4  TPPUMODULE__LOAD_USEDUNITS,  line 1953 of fppu.pas  $0056B91D  TPPUMODULE__TRY_LOAD_PPUFILE,  line 2221 of fppu.pas  $0056BC6C  TPPUMODULE__LOADPPU,  line 2362 of fppu.pas  $0056B2B4  TPPUMODULE__LOAD_USEDUNITS,  line 1953 of fppu.pas  $0056B91D  TPPUMODULE__TRY_LOAD_PPUFILE,  line 2221 of fppu.pas  $0056BC6C  TPPUMODULE__LOADPPU,  line 2362 of fppu.pas  $005B5E07  LOADUNITS,  line 681 of pmodules.pas So, progress.. it's definitely something to do with units I'm including, somehow (maybe order?). I am guilty of several cases of a unit using another unit in it's interface, and the secondary unit uses the original one in it's implementation. It never feels great doing this but it hasn't caused any issues up until now. This weekend I will try patiently carving chunks of units & functionality out of my project and see if I can narrow down what's causing the error. I suspect that all of the complexity is what's actually causing the error though so making it easily reproducible is not going to be easy at all. @Jamie - pretty sure it's not related to my system at all. No problems with space, and have tried the same source files on a couple of different systems (one Intel, one AMD) and different directory structures - same issue on both. ---------------------------------------------------------------------- Eugene Loza · 2024-05-20 06:37 Hmmm... it doesn't look any more helpful to me other than what you've already seen without debug build, that it fails somewhere around coreStrings.pp (hopefully inside of it) as it tries to LOADPPU (i.e. reuse a prebuilt unit, seems like of one of the dependencies of coreStrings.pp). I wonder if Lazarus can give you a more verbose error stack trace? I see you are using complicated compilation configuration, I wonder if you can try setting it up through Lazarus or making a "less configured" build? Because in my cases it usually points to some line of code inside of my code which may be directly or indirectly related to the error you experience. ---------------------------------------------------------------------- TRon · 2024-05-20 08:40 Pardon the intrusion... Quote from: Eugene Loza on May 20, 2024, 08:37:40 amI wonder if Lazarus can give you a more verbose error stack trace? I see you are using complicated compilation configuration, I wonder if you can try setting it up through Lazarus or making a "less configured" build? Because in my cases it usually points to some line of code inside of my code which may be directly or indirectly related to the error you experience. The stacktrace already does that ? Is raises the exception at line 1005 of unit fmodule.pas Lazarus does not help provide you a better trace. The best you could do is adding -va tot the compiler, perhaps followed by using some linker specific options for debugging to be able to spit out even more information but in this case I don't believe it will help. Knowing the revision when/where this happens and try to work your way back to a known working version might be able to pinpoint the change in the source tree that might have caused this error (if any). Also good would be if the problem is reproduceable with a simple(r) example. That makes it a better candidate to add it as an issue (though the current information present would be enough to issue a report). ---------------------------------------------------------------------- Paradice · 2024-05-20 08:56 I'd be willing to try compiling different revisions of the compiler in order to identify the exact version change where the error first appears..... if only I understood git well enough to be able to download specific historical revisions. I'm guessing this is not a capability of FPCUpDeluxe (at least, I don't see it after some clicking around). @Eugene: it's not specific to coreStrings... If I start compiling from coreStrings, it compiles fine and the error occurs in a different unit instead... it always gets 3/4 units in before crashing. ---------------------------------------------------------------------- Eugene Loza · 2024-05-20 09:06 QuoteIs raises the exception at line 1005 of unit fmodule.pasIndeed, this is how it looks. But in my experience Lazarus always points to some line of my code, not of FPC (e.g. https://forum.lazarus.freepasca l.org/index.php/topic,66084.msg516536.html#msg516536 ), even if the internal error happens inside of FPC units with a similar stack trace. Of course, I haven't gotten this specific error myself (yet ), and not such an expert in FPC internals so can't tell for sure. Quoteif only I understood git well enough to be able to download specific historical revisions.Again FPCUpDeluxe can help with that: ---------------------------------------------------------------------- TRon · 2024-05-20 09:25 Quote from: Eugene Loza on May 20, 2024, 11:06:03 amIndeed, this is how it looks. But in my experience Lazarus always points to some line of my code, not of FPC (e.g. https://forum.lazarus.freepascal.org/inde x.php/topic,66084.msg516536.html#msg516536 ), even if the internal error happens inside of FPC units with a similar stack trace. In my experience (but I have ditched the platform for a while now) this should not be a problem on Windows (I am aware your posts/experience states otherwise so can only assume it is a problem in/for some (or all) cases). Things are worse on Linux and Lazarus ads even more confusing traces, unless ofc you know every nitty gritty details of the (LCL) internals by heart. QuoteAgain FPCUpDeluxe can help with that: Indeed that is a (easy) way to do it, particularly if you are not familiar with git. It is similar as (manually) downloading a specific revision from gitlab. Using git though makes things a bit easier because it only requires you to download the source-code once and allows to checkout the different revisions (which is actually the whole purpose of using a vcs) see also here. The process which can be used in this particular case is named bisecting, see also here. edit: BTW @Paradice I have noticed that there in last 2 weeks there is an attempt in the source tree to make some changes/fixes that are able to severely impact compiler behaviour. So you might perhaps want to sit this one through. ---------------------------------------------------------------------- Paradice · 2024-05-20 10:29 @Eugene thank you so much for your patience in providing screenshots - I've got a workflow down now and am (manually) bisecting builds between my known good compiler and today.... so far I'm back to Mar 29th's build, which interestingly, still exceptioned but in a different place. I will provide an update about what build first broke and then attempt to turn it into an error report For completion, this is the crash with Mar 29th revision of compiler (the date still shows today so I'm guessing that's just compilation date): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Free Pascal Compiler version 3.3.1-15491-ge42209457e [2024/05/20] for i386Copyright (c) 1993-2024 by Florian Klaempfl and othersTarget OS: Win32 for i386Compiling E:\Projects\Paradice500\Paradice500.ppCompiling E:\projects\lx7\lx7core.ppCompiling E:\projects\lx7\lx7debug.ppCompiling E:\projects\lx7\lx7strings.ppCompiling E:\projects\lx7\lx7core.ppCompiling E:\projects\lx7\lx7events.ppCompiling E:\projects\lx7\lx7debug.ppCompiling E:\projects\lx7\lx7core.ppCompiling E:\projects\lx7\lx7events.ppError: Compilation raised exception internallyAn unhandled exception occurred at $005B62EC:EAccessViolation: Access violation  $005B62EC  CONNECT_LOADED_UNITS,  line 777 of pmodules.pas  $005B6AB0  PROC_UNIT_IMPLEMENTATION,  line 1079 of pmodules.pas  $00454D67  TTASK_HANDLER__CONTINUE,  line 273 of ctask.pas  $004175E4  COMPILE,  line 310 of compiler.pas ---------------------------------------------------------------------- Eugene Loza · 2024-05-20 10:37 Quoteso far I'm back to Mar 29th's build, which interestingly, still exceptioned but in a different place.My project raises internal errors (or things related to those) in over a dozen different places - some present only in newer compiler versions, some were fixed in newer compiler versions I guess that's the destiny of every project as it grows big enough, especially while using generics. I've managed to isolate and bugreport the most annoying one though ---------------------------------------------------------------------- Paradice · 2024-05-20 10:53 OK, have narrowed it down The Mar 06 2024 build (f41025f5dd7d1b7fb4367f0aceac021a7a1f8478) breaks: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Free Pascal Compiler version 3.3.1-15377-gf41025f5dd [2024/05/20] for i386Copyright (c) 1993-2024 by Florian Klaempfl and othersTarget OS: Win32 for i386Compiling E:\Projects\Paradice500\Paradice500.ppCompiling E:\projects\lx7\lx7core.ppCompiling E:\projects\lx7\lx7debug.ppCompiling E:\projects\lx7\lx7strings.ppCompiling E:\projects\lx7\lx7core.ppCompiling E:\projects\lx7\lx7array.ppCompiling E:\projects\lx7\lx7hash.ppCompiling E:\projects\lx7\lx7debug.ppCompiling E:\projects\lx7\lx7files.ppCompiling E:\projects\lx7\lx7sysinfo.ppCompiling E:\projects\lx7\lx7events.ppCompiling coreStrings.ppError: Compilation raised exception internallyFatal: Compilation abortedAn unhandled exception occurred at $0043908A:EAccessViolation: Access violation  $0043908A  TMODULE__ADDDEPENDENCY,  line 996 of fmodule.pas  $00569F2D  TPPUMODULE__LOAD_USEDUNITS,  line 1951 of fppu.pas  $0056A56C  TPPUMODULE__TRY_LOAD_PPUFILE,  line 2206 of fppu.pas  $0056A8A4  TPPUMODULE__LOADPPU,  line 2342 of fppu.pas  $0056A0B4  TPPUMODULE__LOAD_USEDUNITS,  line 2007 of fppu.pas  $0056A56C  TPPUMODULE__TRY_LOAD_PPUFILE,  line 2206 of fppu.pas  $0056A8A4  TPPUMODULE__LOADPPU,  line 2342 of fppu.pas  $00569F14  TPPUMODULE__LOAD_USEDUNITS,  line 1946 of fppu.pas  $0056A56C  TPPUMODULE__TRY_LOAD_PPUFILE,  line 2206 of fppu.pas  $0056A8A4  TPPUMODULE__LOADPPU,  line 2342 of fppu.pas  $00569F14  TPPUMODULE__LOAD_USEDUNITS,  line 1946 of fppu.pas  $0056A56C  TPPUMODULE__TRY_LOAD_PPUFILE,  line 2206 of fppu.pas  $0056A8A4  TPPUMODULE__LOADPPU,  line 2342 of fppu.pas  $00569F14  TPPUMODULE__LOAD_USEDUNITS,  line 1946 of fppu.pas  $0056A56C  TPPUMODULE__TRY_LOAD_PPUFILE,  line 2206 of fppu.pas  $0056A8A4  TPPUMODULE__LOADPPU,  line 2342 of fppu.pas  $005B3E6B  LOADUNITS,  line 675 of pmodules.pas While the Mar 04 build (bf2a3566fa7e4c9ff400c9ded3cd83a61e4b6e3a0) works as expected: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Free Pascal Compiler version 3.3.1-15331-gbf2a3566fa [2024/05/20] for i386Copyright (c) 1993-2024 by Florian Klaempfl and othersTarget OS: Win32 for i386Compiling E:\Projects\Paradice500\Paradice500.ppUser defined: /*-------------------------*\User defined: | COMPILING: STEAM Edition  |User defined: |     Debugging Information |User defined: \*-------------------------*/Compiling resource E:\Projects\Paradice500\resource500.rcCompiling resource E:\Projects\Paradice500\Paradice500.orLinking E:\Projects\Paradice500\Paradice500.exe85 lines compiled, 0.3 sec, 946656 bytes code, 22372 bytes data1 hint(s) issued  With all versions of the compiler, a full rebuild of the sources works without errors. Then executing a normal compilation immediately afterward shows the differences.  You can see in the Mar 04 version the compiler clearly realizes that none of the units have changed so it *just* builds the main paradice500.pp file.  While the newer compiler versions start recompiling the units again (so already a bug?) and start doing so, then crash shortly afterwards. I can see that there were some commits on 4/5 Mar specifically altering things like load_ppu... so that will be what broke the compilation. Is there anything else I should be collecting to go with a bug report? The sources themselves are still going to be very problematic... ---------------------------------------------------------------------- Eugene Loza · 2024-05-20 10:59 It's also a better idea to include a direct link to the commit: https://gitlab.com/freepascal.org/fpc/source/-/commit/a5caf91f And the commit message indeed seems like a very good candidate for your specific error. Potentially you may not need to cut down your project to reproducible minimum to file a bug report this way then. But it'd be very good if you could provide the project to reproduce the bug (if you are able to, e.g. if the project is opensource or you can send it in private to someone who will take care of the ticket - otherwise it will still need some not-minimal reproduction you can attach to the bugreport in the open). ---------------------------------------------------------------------- TRon · 2024-05-20 11:04 Quote from: Paradice on May 20, 2024, 12:53:15 pmOK, have narrowed it down Thank you very much for having taken the time to do so. QuoteI can see that there were some commits on 4/5 Mar specifically altering things like load_ppu... so that will be what broke the compilation. Yes, that is indeed still a problem. There is an existing report though not as specific as yours so your mileage may vary (I would suggest creating a new report, it can always be marked as duplicate) QuoteIs there anything else I should be collecting to go with a bug report? The sources themselves are still going to be very problematic... No way to re-produce with a minimalistic example ? It can be tiresome but sometimes stripping down an existing project might be able to do that for you. If it is possible to share the sources then please mention that in your report. As mentioned by Eugene that might save you the trouble of cutting down your existing project. ---------------------------------------------------------------------- marcov · 2024-05-20 11:07 It is a known issue that is still not resolved, try to use -Ur as much as possible. ---------------------------------------------------------------------- Paradice · 2024-05-20 11:12 Thank you Marco - have just verified that compiling with -Ur does indeed fix the issue.  Never knew about that switch before now. It's good to find the issue is already known. Would there be any benefit in me attempting to produce a minimum reproducible set of source files that trigger the error? Or is the cause already understood? I'm not particularly looking forward to trying to cut down such a complex interconnected web of a project, but I will do so if it could be helpful. ---------------------------------------------------------------------- TRon · 2024-05-20 11:28 Quote from: Paradice on May 20, 2024, 01:12:56 pmIt's good to find the issue is already known. Sorry, took me some time #40701 ---------------------------------------------------------------------- Paradice · 2024-05-20 11:32 Thank you TRon - I didn't manage to find anything relevant. It's very relieving to know I'm not the only one with the issue haha - Lazarus sources exhibiting the same problem suggests to me it'll be fixed eventually! ---------------------------------------------------------------------- PascalDragon · 2024-05-22 20:20 Quote from: Paradice on May 20, 2024, 01:12:56 pmNever knew about that switch before now. Because it's mainly intended for building a FPC release to avoid unnecessary attempts at recompilation. With main it's currently a workaround until the underlying issue is fixed.