See https://github.com/Ravenbrook/mps-temporary/pull/2 for background.
Reproduction:
1. Fresh Win7 build 7601 (On x86 or x64, same result. I'm using VMware.)
2. Run the setup for Pelles C 7.00
3. Run the setup for Git (with command line option to set path) from http://git-scm.com/download/win
4. Launch Pelles C command prompt from Start menu
5. git clone https://github.com/waywardmonkeys/mps-temporary.git
6. cd mps-temporary
7. git checkout remotes/origin/pellesc (for the record, the exact hash of this repro is 86cd97995641f4606b6d2930a79cf2331a02f7b6)
8. cd code
9. pocc /Ze /O2 mps.c
C:\Users\rb\Documents\mps-temporary\code>pocc /Ze /O2 mps.c
C:\Users\rb\Documents\mps-temporary\code\arenavm.c(496): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\global.c(379): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\tract.c(146): warning #2130: Result ofcomparison is constant.
C:\Users\rb\Documents\mps-temporary\code\trace.c(759): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1074): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1172): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1246): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1651): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1652): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1653): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1654): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1655): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1653): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1585): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1651): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1585): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1660): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\trace.c(1585): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\seg.c(511): warning #2114: Local 'args' is not referenced.
C:\Users\rb\Documents\mps-temporary\code\seg.c(1131): warning #2154: Unreachable code.
C:\Users\rb\Documents\mps-temporary\code\event.c(83): warning #2130: Result of comparison is constant.
C:\Users\rb\Documents\mps-temporary\code\event.c(174): fatal error: Internal error: 'Access violation' at 0x0047b319.
We believe this is a bug in the preprocessor. We do some fairly extensive macro expansion to process the EVENT_LIST macro. We have already tried breaking this macro down into smaller pieces. This works some of the time, for some people, but not others, suggesting that it's a somewhat random buffer overrun. It might even be sensitive to which VM you're running Windows under.
I made some check and it really seems that some overrun occours during preprocessing of macro 'EVENT_LIST', also on real machine (not emulator).
It is an heavy macro indeed. Due to time shortage and software nesting I cannot easily extract a small snippet to reproduce bug and test it.
As I will be able to do it I'll check again.
In the meanwhile if you can extract such a snippet please post it for check.
here is minimal set of headers for testing.
that example don't use standard headers, just empty ones in local folder.
Ah thanks timovjl that's saved me some work.
I compiled the code (and find even one more problem).
First of all if I define 'AVER_AND_CHECK_NONE' it compiles with apparently no problems, this make me suspect of the 'ASSERT' macro in 'check.h'. I made some checks and finally found that replacing:
mps_lib_assert_fail(__FILE__, __LINE__, (condstring)); \
with:
mps_lib_assert_fail("file" , __LINE__, (condstring)); \
remove the access violation.
It seems that the predefined symbol __FILE__ in a so deep nested structure is undefined (or have an invalid pointer). This explain also the casualty in compilation (depends on what there is in memory at pointer address).
I don't know when and if Pelle will fix this problem, if applicable would be better to pass the filename to the 'ASSERT' macro (also to avoid potential problems in other compilers).
The other problem is in 'freelist.c':
typedef union FreelistBlockUnion {
struct {
FreelistBlock next; /* tagged with low bit 1 */
/* limit is (char *)this + fl->alignment */
} small;
struct {
FreelistBlock next;
Addr limit;
} large;
} FreelistBlockUnion;
here you will get:
error #2002: Invalid combination of 'struct' and 'char'
Due to 'small' which is defined in 'rpcndr.h' as a char:
#define small char
This can be solved in 'freelist.c' undefining small before the typedef:
/*****************************************/
#undef small
/*****************************************/
typedef union FreelistBlockUnion {
struct {
FreelistBlock next; /* tagged with low bit 1 */
/* limit is (char *)this + fl->alignment */
} small;
struct {
FreelistBlock next;
Addr limit;
} large;
} FreelistBlockUnion;
Timo you should have missed something (or I'm too tired ? :-)) because I cannot compile your snippet. Are there other problems? Could you check please?
Quote from: frankie on July 11, 2013, 06:13:18 PM
Timo you should have missed something (or I'm too tired ? :-)) because I cannot compile your snippet. Are there other problems? Could you check please?
it was just for testing preprosessing !
for that error: eventdef.h(400): fatal error: Internal error: 'Access violation' at 0x004c93f4.
Hi Timo,
yes you're right the errors are only for undefined macros and symbols created by the offending macro.
Sorry I was really tired :)
P.S. I removed the workaround. It was badly wrong! :(