MPS issue job004113

TitleMPS does not compile with GCC 7.3
Statusclosed
Priorityessential
Assigned userGareth Rees
OrganizationRavenbrook
DescriptionIn the master sources at changelevel 195127:

    $ make -f xci6gc.gmk VARIETY=cool
           ...
    ss.c: In function 'StackScan':
    ss.c:49:9: error: variable 'warmest' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
        void *warmest;
              ^~~~~~~
AnalysisWe don't actually call longjmp on this jump buffer, but there seems to be no way to tell that to GCC.

The POSIX specification for longjmp [1] says "the values of objects of automatic storage duration are unspecified if they meet all the following conditions: They are local to the function containing the corresponding setjmp() invocation; They do not have volatile-qualified type; They are changed between the setjmp() invocation and longjmp() call."

In this case "warmest" meets the three criteria. But we can swap the assignment to warmest so that it comes before the call to STACK_CONTEXT_SAVE, and then it won't be clobbered by longjmp.
How foundmanual_test
Evidence[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/longjmp.html
Created byGareth Rees
Created on2018-09-23 20:23:42
Last modified byGareth Rees
Last modified on2018-10-22 13:51:50
History2018-09-23 GDR Created.

Fixes

Change Effect Date User Description
195136 closed 2018-09-23 20:31:52 Gareth Rees Move assignment so as to avoid "variable 'warmest' might be clobbered by 'longjmp'".