In article <1106055734.834784.209340@[EMAIL PROTECTED]
>,
"SiamGod" <ed.woods@[EMAIL PROTECTED]
> wrote:
> I put in
> check(Metrowerks::msl_settings());
> nothing happened.
>
> I tried
> Test << " asdf" << 1;
>
> no problem
>
> Test << endl;
> crashes with a call stack . The last function was bufferedbuf(...)::
> write_buf()
> on the line right after the while()
> count = write_chars(uncbeg_, uncnxt_ - uncbeg_)
>
> when I step into write_chars it calls fread(buf,1, n, file_)
> and file_ is NULL. Stepping into the assembly, i get to a point where
> it calls
> ntdll.dll and crashes.
>
> I hope this is enough locate the problem.
Yes, thank you for your aid. I have located the bug in
<msl_bufferedbuf>. You can patch it by opening that file (under
MSL_C++/MSL_Common/Include/) and search for the member function:
bufferedbuf<charT, traits>::setbuf(char_type* s, _STD::streamsize n)
The definition puts the stream into write mode mistakenly sometimes and
that is what is happening in your example. Here is the fixed function:
template <class charT, class traits>
_STD::basic_streambuf<charT,traits>*
bufferedbuf<charT, traits>::setbuf(char_type* s, _STD::streamsize n)
{
bool pa = put_active();
if (sync() < 0)
return 0;
partition_neutral();
if (s == 0)
{
if (owns_buffer_)
delete [] buffer_;
buffer_ = 0;
buffer_size_ = _STD::max(_STD::max(max_length_ * 2 /
sizeof(char_type), (_CSTD::size_t)n), (_CSTD::size_t)minbufsize);
buffer_ = new char_type[buffer_size_];
owns_buffer_ = true;
buffered_ = n != 0;
}
else
{
if (n < max_length_ * 2 / (_STD::streamsize)sizeof(char_type))
return 0;
if (owns_buffer_)
delete [] buffer_;
buffer_ = s;
buffer_size_ = (_CSTD::size_t)n;
owns_buffer_ = false;
buffered_ = true;
}
if (buffered_ && pa)
partition_put();
return this;
}
After applying this patch you should rebuild all of the MSL libraries
which is most easily done with BuildLibraries.x86.mcp found under
(MSL_Build_Projects)/x86/.
Sorry for the bug, and thanks for reporting it and helping to diagnose
it.
-Howard


|