Norcroft compiler error
Chris Johnson (125) 825 posts |
I was trying to compile the webp library (Google’s new web image format) and one of the source files has thrown up an error I have never seen before. I reproduce the compiler output. cc -c -fahi -depend !Depend -throwback -memaccess -L22-S22-L41 -IC: -o o.quant c.quant Internal inconsistency: either resource shortage or compiler fault. If you cannot alter your program to avoid this failure, please contact your supplier AMU: * ‘all’ not re-made because of errors * Before I start bu****ing around with code that I do not fully understand, has anyone any hint on what to look for in the code. The original paper manual is very brief on possible cause. Apart from doing things like increasing wimp slot, it doesn’t offer much. I am calling amu from a taskobey file simply with the -f makefilename argument. Thanks in advance to anyone who can throw me a lifeline before I get out of my depth. |
Jeffrey Lee (213) 6048 posts |
“Fatal internal error: corrupted register” sounds like a compiler bug to me. Which version of the webp sources are you using? I’ve had a quick look at the latest sources and the error line numbers don’t seem to match up with the code, so I guess you’re using a slightly different version than what’s in their git repo. (I suspect the bug will still be there with the latest code – but without trying it myself I was just curious to see the exact code that’s causing it to trip up) |
Chris Johnson (125) 825 posts |
Thanks for the reply, Jeffrey. The version I downloaded was libwebp-0/2/1 via the tar.gz archive. The error line number corresponds to the closing brace of a function. Just this function is below (apologies for clogging up the forum).
Line 721 is the rd16.SD = tlambda ? MULT…. line and 738 is the closing brace. |
Chris Mahoney (1684) 2165 posts |
Did you ever get to the bottom of this? I just tried to compile SQLite and got a similar error: "c.sqlite3", line 16442: Fatal internal error: genpointer1 Internal inconsistency: either resource shortage or compiler fault. If you cannpot alter your program to avoid this failure, please contact your supplier AMU: *** exit (1) *** At first I thought that this was due to SQLite’s huge code file (155867 lines!) but it also happens if I use the “split” version which is spread over 100-or-so files. Here’s the function where it’s falling over: SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){ static SQLITE_WSD FuncDef aDateTimeFuncs[] = { #ifndef SQLITE_OMIT_DATETIME_FUNCS FUNCTION(julianday, -1, 0, 0, juliandayFunc ), FUNCTION(date, -1, 0, 0, dateFunc ), FUNCTION(time, -1, 0, 0, timeFunc ), FUNCTION(datetime, -1, 0, 0, datetimeFunc ), FUNCTION(strftime, -1, 0, 0, strftimeFunc ), FUNCTION(current_time, 0, 0, 0, ctimeFunc ), FUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc), FUNCTION(current_date, 0, 0, 0, cdateFunc ), #else STR_FUNCTION(current_time, 0, "%H:%M:%S", 0, currentTimeFunc), STR_FUNCTION(current_date, 0, "%Y-%m-%d", 0, currentTimeFunc), STR_FUNCTION(current_timestamp, 0, "%Y-%m-%d %H:%M:%S", 0, currentTimeFunc), #endif }; int i; FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions); FuncDef *aFunc = (FuncDef*)&GLOBAL(FuncDef, aDateTimeFuncs); for(i=0; i<ArraySize(aDateTimeFuncs); i++){ sqlite3FuncDefInsert(pHash, &aFunc[i]); } } Line 16442 is the line just after the #ifndef. FUNCTION itself is defined elsewhere (beginning on line 11307) and I don’t want to clutter the forum up too much so I’ll just leave a link to the source. GCC may handle this a little better; I haven’t tried it yet. |
Ronald May (387) 407 posts |
GCC may handle this a little better; I haven’t tried it yet. I compiled the source you linked to with native GCC 4.1.2 sqlite -version is a bit strange |
Chris Mahoney (1684) 2165 posts |
Thanks for that. Interestingly it won’t compile under GCC 4.7.4 (it fills a DA up to 32 MB then crashes with an out of memory error) so I’m downloading 4.1.2 now. The SQLite docs suggest using -DSQLITE_OMIT_LOAD_EXTENSION to avoid having to use -ldl although this results in a couple of features not working (admittedly ones that I’m not likely to use anyway). |
Ben Avison (25) 445 posts |
It certainly looks like it could be a compiler bug. It’s best to file this in the bug tracker or email it to (ctools at riscosopen.org) as we can’t guarantee to monitor all the forums for bug reports. It would be most helpful if you could try chopping pieces out of the function until you find the simplest code sequence which will generate the bug. In any case, we would need you to provide a preprocessed version of the source code (cc -E) as well as the command line used to ensure that we can reproduce it correctly. |
Chris Mahoney (1684) 2165 posts |
I’ve begun trimming it down – I’ve knocked about 145000 lines out so far :) Hopefully I’ll be able to get it down to just a few lines, but since I’m completely unfamiliar with the code I’m basically having to do a “chop out this chunk, compile, see whether it fails” so it might take me a little while! |
Chris Mahoney (1684) 2165 posts |
Well, I managed to get to down to 18 lines (including whitespace) so I feel like I’ve accomplished that, it least :) The bug tracker appears to be down at the moment (doesn’t load past a blank page) so I’ll try it again in the morning. If there’s no luck there then I’ll email it through. For the curious, I’ve put the trimmed code here. [Edit: Forgot to say that I’ve also added a simple main() stub so that it’s actually a valid app]. |
Rick Murray (539) 13840 posts |
Mmm, I’ve been getting this some times recently (today the bug tracker, the other day the forum when I clicked on Save Reply…):
Lame DDOS or RISC OS is now insanely popular? |
Chris Mahoney (1684) 2165 posts |
I’m getting that message now too, but it was just “loading infinitely” a few hours ago. |
Steve Pampling (1551) 8170 posts |
I’ve seen that delay before but not for some months. |
Andrew Rawnsley (492) 1445 posts |
For what it’s worth, I saw a similar compiler issue when working on SharpEye a couple of weeks ago. I have just been sorting out permission to distribute the appropriate code. I haven’t succeeded in making it compile in any 5.68+ version of CC. However, it did compile with older Castle-era versions (5.5x?) and the -memaccess stuff, which ultimately allowed me to get a working alignment-safe version of SharpEye. I guess one for Ben when he has some spare time (!!). |
Chris Mahoney (1684) 2165 posts |
Bug tracker still isn’t behaving so I’ve emailed it. |
Chris Mahoney (1684) 2165 posts |
Crisis averted! After closer investigation of the original code, it’s actually doing the wrong thing. The following is simplified, to make the problem obvious: #if !defined(__GNUC__) # define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X]) #else # define SQLITE_INT_TO_PTR(X) ((void*)(X)) #endif The second #define works correctly so it looks like a logic error in figuring out which compiler is being used (there are actually four cases in the original code but those two are the relevant ones). I’ll play with it a bit more when I get home. |
Ronald May (387) 407 posts |
The second #define works correctly so it looks like a logic error You may get that right by defining Edit:If line 8305 was altered to exclude Norcroft as well as GNUC you would then drop through to line 8312 OK I think. I dont know what the macro for Norcroft is but |
Rick Murray (539) 13840 posts |
The compiler probably shouldn’t crash, even on dodgy code, but still… 1 Contrary to popular belief, I do actually have one…err…somewhere <rummage><rummage> |
Chris Mahoney (1684) 2165 posts |
Defining PTRDIFF and/or HAVE_STDINT_H were on my to-do list :) Hopefully there’s a macro for Norcroft too; the code’s a bit odd as it’ll catch “not GNUC” before checking for STDINT! I’m home in 4 hours… As for the code itself, yup, it makes my brain hurt too (I’m fairly sure that I have one!) |
Chris Mahoney (1684) 2165 posts |
#elif !defined(__GNUC__) && !defined(__CC_NORCROFT) does the trick :) Now to handle all the other errors (which aren’t crashing the compiler!) |
Ronald May (387) 407 posts |
That looks correct, but we /are/ assuming Norcroft cannot do GNUC functions across the board, if it could, (I have no idea) then it would be more correct to define GNUC if CC_NORCROFT is present. |
Chris Mahoney (1684) 2165 posts |
That change is the only one required; it compiles with no other changes. I know that I mentioned “other errors” but those ended up being fixable by adding “CDEFINES = -DSQLITE_THREADSAFE=0 -DSQLITE_OS_OTHER” to the makefile. |