This newly added test triggers and breaks VC6 builds on all my win32 machines:
Making GTK /famine/win32build/test/Pike/7.6/build/windows_xp-5.1.2600-i686/pike -DNOT_INSTALLED -DPRECOMPILED_SEARCH_MORE -m/famine/win32build/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike /famine/win32build/test/Pike/7.6/src/post_modules/GTK/new_build_pgtk.pike --source='/famine/win32build/test/Pike/7.6/src/post_modules/GTK/source/'\ /famine/win32build/test/Pike/7.6/src/post_modules/GTK/output/few.pike W:\test\Pike\7.6\src\program.c:8075: Fatal error: VirtualProtect failed, code 87 for: VirtualProtect( 01331270, 0, PAGE_EXECUTE_READWRITE, &old_prot ) p->num_program: 0 sizeof( p->program[0] ): 1 No stack - no backtrace.
87 is AKA invalid parameter, and yes; a dwSize of 0 probably not appreciated by VirtualProtect. I haven't digged any deeper in it. Is make_program_executable() supposed to be handed programs without any programs in?
Index: src/program.c =================================================================== RCS file: /pike/data/cvsroot/Pike/7.6/src/program.c,v retrieving revision 1.573 retrieving revision 1.574 diff -u -u -r1.573 -r1.574 --- src/program.c 4 Jul 2006 14:38:16 -0000 1.573 +++ src/program.c 5 Aug 2006 20:35:41 -0000 1.574 @@ -2,11 +2,11 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: program.c,v 1.573 2006/07/04 14:38:16 mast Exp $ +|| $Id: program.c,v 1.574 2006/08/05 20:35:41 mast Exp $ */
#include "global.h" -RCSID("$Id: program.c,v 1.573 2006/07/04 14:38:16 mast Exp $"); +RCSID("$Id: program.c,v 1.574 2006/08/05 20:35:41 mast Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -8069,8 +8069,10 @@ { #ifdef _WIN32 DWORD old_prot; - VirtualProtect((void *)p->program, p->num_program*sizeof(p->program[0]), - PAGE_EXECUTE_READWRITE, &old_prot); + if (!VirtualProtect (p->program, + p->num_program * sizeof (p->program[0]), + PAGE_EXECUTE_READWRITE, &old_prot)) + Pike_fatal ("VirtualProtect failed, code %d.\n", GetLastError());
#else /* _WIN32 */
In 7.7, make_program_executable() starts with the test
if (!p->num_program) return;
Adding that test in 7.6 too should fix the problem.
Well, yes, make_program_executable() is called for all programs, even those without actual code in them.
Checked in. Unfortunately it then goes on to complain about illegal addresses as seen below, but debugging that will have to wait until tomorrow.
/famine/win32build/test/Pike/7.6/build/windows_xp-5.1.2600-i686/pike -DNOT_INSTALLED -DPRECOMPILED_SEARCH_MORE -m/famine/win32build/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike /famine/win32build/test/Pike/7.6/src/post_modules/GTK/new_build_pgtk.pike --source='/famine/win32build/test/Pike/7.6/src/post_modules/GTK/source/'\ /famine/win32build/test/Pike/7.6/src/post_modules/GTK/output/few.pike W:\test\Pike\7.6\src\program.c:8079: Fatal error: VirtualProtect failed, code 487. VirtualProtect(01639008, 28843, PAGE_EXECUTE_READWRITE, &old_prot) p->num_program: 28843 sizeof( p->program[0] ): 1 Backtrace at time of fatal: W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:349: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->compile_string("#pike __REAL_VERSION__\n\n#pragma strict_types\n\n//! General functions to operat"+[20571],"W:/test/Pike/7.6/lib/modules/Array.pmod",0,object_program(Array),object(W:/test/Pike/7.6/lib/modules/Array.pmod),UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:819: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->low_findprog("W:/test/Pike/7.6/lib/modules/Array.pmod","",0,1) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:933: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->findprog("W:/test/Pike/7.6/lib/modules/Array.pmod",".pmod",0,1) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:964: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->low_cast_to_program("W:/test/Pike/7.6/lib/modules/Array",0,0,1) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1145: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->low_cast_to_object("W:/test/Pike/7.6/lib/modules/Array.pmod",0,0) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1343: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1177)->low_ind("Array",UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1413: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1177)->ind("Array") W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1437: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1177)->`[]("Array") W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1587: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1527)->ind("Array") W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1625: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1527)->`[]("Array") W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:2132: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->resolv_base("Array","W:/test/Pike/7.6/lib/modules/Parser.pmod/C.pmod",0) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:2166: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->resolv("Array","W:/test/Pike/7.6/lib/modules/Parser.pmod/C.pmod",0) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:349: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->compile_string("//\n// This file needs to support old pikes that e.g. don't understand\n// "#pike". Some of them fail when"+[10627],"W:/test/Pike/7.6/lib/modules/Parser.pmod/C.pmod",UNDEFINED,object_program(Parser.C),0,UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:819: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->low_findprog("W:/test/Pike/7.6/lib/modules/Parser.pmod/C.pmod","",UNDEFINED,UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:933: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->findprog("W:/test/Pike/7.6/lib/modules/Parser.pmod/C.pmod",".pmod",UNDEFINED,UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:976: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->low_cast_to_program("C","W:/test/Pike/7.6/lib/modules/Parser.pmod/Pike.pmod",UNDEFINED,UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:998: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->cast_to_program("C.pmod","W:/test/Pike/7.6/lib/modules/Parser.pmod/Pike.pmod",UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1133: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->handle_inherit("C.pmod","W:/test/Pike/7.6/lib/modules/Parser.pmod/Pike.pmod",UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:349: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->compile_string("//\n// This file needs to support old pikes that e"+[7292],"W:/test/Pike/7.6/lib/modules/Parser.pmod/Pike.pmod",0,object_program(Parser.Pike),object(W:/test/Pike/7.6/lib/modules/Parser.pmod/Pike.pmod),UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:819: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->low_findprog("W:/test/Pike/7.6/lib/modules/Parser.pmod/Pike.pmod","",0,1) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:933: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->findprog("W:/test/Pike/7.6/lib/modules/Parser.pmod/Pike.pmod",".pmod",0,1) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:964: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->low_cast_to_program("W:/test/Pike/7.6/lib/modules/Parser.pmod/Pike",0,0,1) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1145: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->low_cast_to_object("W:/test/Pike/7.6/lib/modules/Parser.pmod/Pike.pmod",0,0) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1343: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1177)->low_ind("Pike",UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1413: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1177)->ind("Pike") W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1437: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1177)->`[]("Pike") W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1587: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1527)->ind("Pike") W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1625: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:1527)->`[]("Pike") W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:349: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->compile_string("#!/usr/bin/env pike\n\n\nstring destination_dir = "";\n\n/* Start of re"+[46831],"W:/test/Pike/7.6/src/post_modules/GTK/new_build_pgtk.pike",UNDEFINED,W:/test/Pike/7.6/src/post_modules/GTK/new_build_pgtk,0,UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:819: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->low_findprog("W:/test/Pike/7.6/src/post_modules/GTK/new_build_pgtk",".pike",UNDEFINED,UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:928: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->findprog("W:/test/Pike/7.6/src/post_modules/GTK/new_build_pgtk",".pike",UNDEFINED,UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:964: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->low_cast_to_program("W:/test/Pike/7.6/src/post_modules/GTK/new_build_pgtk","W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike",UNDEFINED,UNDEFINED) W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike:998: object(W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike)->cast_to_program("W:/test/Pike/7.6/src/post_modules/GTK/new_build_pgtk.pike","W:/test/Pike/7.6/build/windows_xp-5.1.2600-i686/master.pike",UNDEFINED)
That's because the solution with a separate VirtualProtect call doesn't work at all. It's fixed in 7.7 by using the mexec_malloc stuff on windows too to allocate PAGE_EXECUTE_READWRITE pages from the start, but the patch for that is a bit largish (several checkins on August 9th).
There is a chance that it works anyway if dlmalloc is disabled (if the windows builtin heap manager never concatenates blocks allocated by different VirtualAlloc calls).
Actually, I just got it to work (at least to build) by disabling the machine code. I did that because eval was called with -1 as second argument according to the stack when the callee used a static 0 as second argument. Admittadly VC6 seems to have a rather hard time with some of the pike structures, so it might be a debugger artifact, but it built anyway. Running verify on it now.
True, disabling machine code is an alternative workaround.
Visual Studio has a tendency to show some bogus stack frames when it fails on generated machine code, so that kind of bugs are a bit tricky to recognize. WinDbg is somewhat better.
True, disabling machine code is an alternative workaround.
Visual Studio has a tendency to show some bogus stack frames when it fails on generated machine code, so that kind of bugs are a bit tricky to recognize. WinDbg is somewhat better.
pike-devel@lists.lysator.liu.se