From: Charlie Savage Date: 2009-02-23T12:44:32+09:00 Subject: [ruby-core:22345] [Bug #1162] Build Assertion Failure with VC+++ - Incorrect flushing of stdout/stderr Issue #1162 has been updated by Charlie Savage. >It is a compile time flag and irrelevant to debug built msvcrt. Not sure what you mean. VC2008 (and earlier versions) set the -RTC1 flag by default when creating debug builds of C/C++ projects. The -RTC1 flag causes the binary to use a debug version of the C runtime libraries. These libraries are helpful in diagnosing memory problems or other incorrect usages of the C runtime library. Since the Ruby build process depends on creating a working version of miniruby.exe, setting -RTC1 means you can't build a debug version of Ruby because miniruby crashes when invoked with an assertion error. > It does mention about FlushFileBuffers() only, not _commit(). > And says just it returns an error, not make the process > crashed. Well commit calls FlushFileBuffers, so its seems that documentation is applicable. And when you look at the documentation for _commit it says http://msdn.microsoft.com/en-us/library/17618685(VS.80).aspx If fd is an invalid file descriptor, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue... In a debug build, execution is *not* allowed to continue because an assertion error is raised. > Feel free to call it a bug or a paranoiac false assertion of > msvcrt, and now disabled already, at r22337. r22337 does not fix the problem. Try it with a debug build using VC2008 using the standard values set by VC2008 (/Od /D "WIN32" /D "_DEBUG" /Gm /EHsc /RTC1 /MDd /W3 /c /ZI /TP). It will crash. I still consider this a bug - Ruby is passing an invalid file handle to commit. In a release build this will generate a "Invalid handle error" error code which Ruby ignores. In a debug build it triggers an assertion failure that causes Ruby to crash. Once again the fix is simple and only affects windows: #ifdef _WIN32 - fsync(fptr->fd); + if (io != rb_stdout && io != rb_stderr) + fsync(fptr->fd); #endif The only new line of code is the if statement. So, I really think this is the way to solve the problem and r22337 should be reverted. Thanks, Charlie is used by default VC2008 is of Yes, its a compile time flag. What do you mean though its irrelevant to a debug built msvcrt? ---------------------------------------- http://redmine.ruby-lang.org/issues/show/1162 ---------------------------------------- http://redmine.ruby-lang.org