Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2003-12-12 12:38:04


>Robert Ramey wrote:

>> Alexey Nikitin wrote:
>>
>> > // test array of objects
>>> > A a_array[10];
>> > {
>> > test_ostream os(testfile, TEST_STREAM_FLAGS);
>> > test_oarchive oa(os);
>> > oa << boost::serialization::make_nvp("a_array", a_array);
>> > }
>>
>> >At exit from block happens access violation, because os tries to use
>codecvt
>>> >object deleted in oa destructor.
>
>> The archive classes use the locale statesaver to restore the the streams
>> codecvt facet when the archive is destroyed. So I'm not sure why
>> this is happening. Its odd to me that no one else has reported
>> this problem. It would be interesting and helpful if you could trace
through
>> the execution of the archive descructor ( and through the state saver
>> destructor) and report your results.

>I am trace the execution of the archive descructor and find that function
>imbue in basic_filebuf "has no effect unless it is called before any I/O is
>performed on the stream". Quotation from STLPort implementaton of STL. I am
>send next message to STLPort forum:

>------------------------------------------------------------------
>STLPort-4.6 lack of correspondence to Standard (may be)
>27.8.1.4
..
>void imbue(const locale& loc);

>17. Precondition: If the file is not positioned at its beginning and the
>encoding of the current locale as determined by a_codecvt.encoding() is
>state-dependendent (22.2.1.5.2) then that facet is the same as the
>corresponding facet of loc.

>file stl/_fstream.c:
>--- line 424 ---
>// Change the filebuf's locale. This member function has no effect
>// unless it is called before any I/O is performed on the stream.
>template <class _CharT, class _Traits>
>void basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
>{
>if (!_M_in_input_mode &&! _M_in_output_mode && !_M_in_error_mode) {
>this->_M_setup_codecvt(__loc);
>}
>}
>--- line 432 ---

This suggests to me that the state_saver library is somehow imcompatible
with STL Port in that it doesn'nt "unimbue". This leaves the locale pointer
unchanged in the output stream which crashes in its destructor.

In my view this points to difference between STLPort and other implementations
of the standard library.

I'm not sure of the best place to address this. Can anyone help here?

Robert Ramey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk