William A. Rowe Jr. wrote on 2011-02-04: > On 2/4/2011 3:49 PM, Steve Hay wrote: >> >> Yes, Apache, Perl and mod_perl were all brand-new builds done one > immediately after another on the same machine, using the same VS2010 > installation for them all. > > I presume by Apache you mean httpd as well as apr and apr-util, etc.
Yes, the full httpd-2.2.17-win32-src.zip built with "nmake /f Makefile.win installr". > >> Also, note that the test.cpp program that I attached in my original > post (which you've quoted the stack trace from above) is a self- > contained standalone program, not linked to anything other than > standard MS libraries. The functions in it are copied directly from the > APR code with just minor renaming, macro expansion and comment removal. > > Ack. > >> Actually, there is one comment in httpd- >> 2.2.17\srclib\apr\misc\win32\apr_app.c that sounds very pertinent: >> >> * _dbg_malloc/realloc is used in place of the usual API, in order >> * to convince the MSVCRT that it created these entities. If we >> * do not create them as _CRT_BLOCK entities, the crt will fault >> * on an assert. We are not worrying about the crt's locks here, >> * since we are single threaded [so far]. >> >> It looks like the original environ[] was allocated by msvcr100.dll > using something other than a function matching the HeapFree() function > where the crash finally happens. The CRT code is trying to free the > existing PATH in its environment before setting the new value coming > from _putenv(), and it is that free that crashes, presumably because the > APR re-processing of the environ entities didn't fool MSVCRT well enough? > > That makes sense, and it should be easy to make that conditional on the > vc version. > Now the question is where were these allocated from in MSVCR100? Only > a trip through > the crt sources will help out, there. Indeed, but looking through the VS2010 CRT source code the environment seems to be initialized in stdenvp.c using _calloc_crt, which should match the _free_crt call in setenv.c line 211 where it all goes wrong, so I'm confused why it's crashing. The VS2008 CRT source code looks the same in this area too.
