Issue #1162 has been updated by Charlie Savage.


Hi Nobu,

Sorry, I've been out the last few days.

> You are wrong about -RTC1.  It does emit checking code but
> doesn't imply to link with msvcrtd.lib.  -MDd flag directs it.
> You can compile with -RTC1 and no -MDd.

Yes, I agree these are different things.  I was just pointing out that a debug build in Visual Studio by default sets both of these flags (create a new project, look at the debug build flags). 

> Your ``fix'' simply doesn't work with other IOs.  Try:

  open("CONOUT$", "w").flush

Yes, that fails with the same assertion error, with or without my patch.  And it fails for the exact same reason - you can't use _commit to flush CONOUT because its a console buffer. 

As I've stated earlier, I think using _CrtSetReportMode is the wrong solution.  First it simply ignores the problem and second it could potentially hide other, more serious issues.

Maybe there is a better solution we could come up with?  The goal is not to call flush on console buffers on windows, because that either returns a ERROR_INVALID_HANDLE error or causes an assertion failure (when the executable is built with -RTC1).  So either way you look at it, these calls on Windows are incorrect.

Is there some way that console buffers (STDERR, STDOUT, CONOUT) can be easily recognized?  Maybe checking fptr->stdio_file (its NULL in your example)?

Thanks,

Charlie
----------------------------------------
http://redmine.ruby-lang.org/issues/show/1162

----------------------------------------
http://redmine.ruby-lang.org