From: Duft M. <Mar...@sa...> - 2006-10-19 12:15:35
|
Cool! ;o) It just came into my mind, that the environment stuff additionally uses = a fixed buffer (4096 chars) somewhere. This is fixed in the next version = of wgcc, but you should have the old sources... So wgcc now works fine with a cc build? Cheers, Markus=20 -----Original Message----- From: Jerker B=E4ck [mailto:jer...@ho...]=20 Sent: Thursday, October 19, 2006 1:44 PM To: int...@li... Cc: Duft Markus Subject: BUG - POSIX build I finally got the posix debugger working - yess! And finally found the bug in wgcc preventing the MS build. The current wgcc posix build will not even make it to main(). It throws = an exception during construction of the context instance of class = Context located in Context.cpp(700): Context::Context() ... more exactly here: paths.c =3D Environment::getPaths(COMPILER_C); =3D> stop - stack buffer overrun. The output looks like this: --------------------------------------------------- *** A stack buffer overrun occurred in ?=01: This is usually the result of a memory copy to a local buffer or = structure where the size is not properly calculated/checked. If this bug ends up in the shipping product, it could be a severe = security hole. The stack trace should show the guilty function (the function directly = above __report_gsfailure). *** enter .exr 49ACA2A0 for the exception record *** then kb to get the faulting stack Windows has triggered a breakpoint in wgcc.SUA.exe. This may be due to a corruption of the heap, and indicates a bug in = wgcc.SUA.exe or any of the DLLs it has loaded. The output window may have more diagnostic information --------------------------------------------------- At this point _mainCRTStartup have not been started yet: Program flow =3D> >wgcc.SUA.exe!__PosixProcessStartup(int calledFromldso=3D0, _startupData = * incomingStartup=3D0x00000000) >wgcc.SUA.exe!_init(int argc=3D1, char * * argv=3D0x00010640, char * * environ=3D0x00010648) >wgcc.SUA.exe!_cinit() >wgcc.SUA.exe!_initterm(void (void)* * pfbegin=3D0x00462094, void = (void)*=20 >* pfend=3D0x004620f0) >wgcc.SUA.exe!wgcc::`dynamic initializer for 'context''() Line 703 C++ >wgcc.SUA.exe!wgcc::Context::Context() Line 35 C++ code in Environment.cpp is executed =3D> exception, stack buffer = overrun. >wgcc.SUA.exe!_mainCRTStartup() >wgcc.SUA.exe!main(int argc=3D1, char * * argv=3D0x00010640) Line 100 = C++ =09 The construction and memory allocation done in Environment.cpp should be = delayed until we enter main() I suggest a Context::init() function from main() like this: extern "C" int __cdecl main(int argc, char ** argv) { wgcc::CommandLine::OptionManager manager(wgcc::options, false); if(!wgcc::context.init()) return ERROR_CODE; ... and bool Environment::getPaths(Destination dest, std::list<std::string>& = paths); bool Context::init() { // Supply existing list by reference if(!Environment::getPaths(COMPILER_C, paths.c)) return false; if(!Environment::getPaths(COMPILER_CPP, paths.cpp)) return false; if(!Environment::getPaths(LINKER, paths.linker)) return false; return true; } When I applied this fix I got a working build from cc and VS2005 I attach a code analysis build log FYI Note: The dynamic_cast's mentioned earlier is still turned into = static_cast's regards Jerker |