[filesystem] static object throws

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[filesystem] static object throws

Vladimir Prus

Hi,
an application of mine just suddenly crashed before entering 'main', with the
following stacktrace:

    #5  0xb7eb7106 in __cxa_throw () from /usr/lib/libstdc++.so.5
    #6  0xb7e6ccb0 in std::__throw_runtime_error ()
        from /usr/lib/libstdc++.so.5
    #7  0xb7eb5c8e in std::locale::facet::_S_create_c_locale ()
        from /usr/lib/libstdc++.so.5
    #8  0xb7e96554 in std::locale::_Impl::_Impl ()
         from /usr/lib/libstdc++.so.5
    #9  0xb7e768e9 in std::locale::locale () from /usr/lib/libstdc++.so.5
    #10 0xb78f6922 in __static_initialization_and_destruction_0
       (__initialize_p=1, __priority=65535)
        at /space/NM/boost/libs/filesystem/src/path.cpp:29

And the line in question contains just:

29        std::locale loc("");

This is CVS as of today. The problem was that I incorrectly set the
LC_MESSAGES environment variable. However, I think that exception from static
object is not so good idea. I can't catch it, so the error reporting just
reads "Aborted".

Maybe, this can be converted into a function with static variable, so that the
static variable is only initialized on the first call?

TIA,
Volodya
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [filesystem] static object throws

Beman Dawes

"Vladimir Prus" <[hidden email]> wrote in message
news:[hidden email]...

>
> Hi,
> an application of mine just suddenly crashed before entering 'main', with
> the
> following stacktrace:
>
>    #5  0xb7eb7106 in __cxa_throw () from /usr/lib/libstdc++.so.5
>    #6  0xb7e6ccb0 in std::__throw_runtime_error ()
>        from /usr/lib/libstdc++.so.5
>    #7  0xb7eb5c8e in std::locale::facet::_S_create_c_locale ()
>        from /usr/lib/libstdc++.so.5
>    #8  0xb7e96554 in std::locale::_Impl::_Impl ()
>         from /usr/lib/libstdc++.so.5
>    #9  0xb7e768e9 in std::locale::locale () from /usr/lib/libstdc++.so.5
>    #10 0xb78f6922 in __static_initialization_and_destruction_0
>       (__initialize_p=1, __priority=65535)
>        at /space/NM/boost/libs/filesystem/src/path.cpp:29
>
> And the line in question contains just:
>
> 29        std::locale loc("");
>
> This is CVS as of today. The problem was that I incorrectly set the
> LC_MESSAGES environment variable. However, I think that exception from
> static
> object is not so good idea. I can't catch it, so the error reporting just
> reads "Aborted".

Ah! This may expain so other error reports of aborts before main() has
started.

> Maybe, this can be converted into a function with static variable, so that
> the
> static variable is only initialized on the first call?

OK, this has been changed in CVS. Please try it with the same LC_MESSAGES
problem, and let me know if the exception occurs at a more appropriate time.

I'm also wondering if the path.cpp code should catch the exception and call
boost::throw_exception() with a filesystem_error. What do you think about
doing that? Would it have made diagnosing the problem easier for you?

Thanks very much for the detailed report and suggested fix. That is ever so
much more helpful than a bald "it crashed" report.

--Beman



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [filesystem] static object throws

Vladimir Prus
Beman Dawes wrote:

>> Maybe, this can be converted into a function with static variable, so
>> that the
>> static variable is only initialized on the first call?
>
> OK, this has been changed in CVS. Please try it with the same LC_MESSAGES
> problem, and let me know if the exception occurs at a more appropriate
> time.

Sorry, no, because of this another static object:

   const std::codecvt<wchar_t, char, std::mbstate_t> *
          converter(
             &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
              ( loc() ) );

which cals 'loc' before 'main' is called, and gives the same problem.

> I'm also wondering if the path.cpp code should catch the exception and
> call boost::throw_exception() with a filesystem_error. What do you think
> about doing that? Would it have made diagnosing the problem easier for
> you?

I don't know because I don't know the what() text of the exception thrown on
wrong locale. As soon as we get *some* exception caught, things will be
clearer.

Thanks,
Volodya


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [filesystem] static object throws

Beman Dawes

"Vladimir Prus" <[hidden email]> wrote in message
news:dujffj$njo$[hidden email]...

> Beman Dawes wrote:
>
>>> Maybe, this can be converted into a function with static variable, so
>>> that the
>>> static variable is only initialized on the first call?
>>
>> OK, this has been changed in CVS. Please try it with the same LC_MESSAGES
>> problem, and let me know if the exception occurs at a more appropriate
>> time.
>
> Sorry, no, because of this another static object:
>
>   const std::codecvt<wchar_t, char, std::mbstate_t> *
>          converter(
>             &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
>              ( loc() ) );
>
> which cals 'loc' before 'main' is called, and gives the same problem.

Grrr.... Sorry. Fixed in CVS.

--Beman



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [filesystem] static object throws

Vladimir Prus
Beman Dawes wrote:

>> Sorry, no, because of this another static object:
>>
>>   const std::codecvt<wchar_t, char, std::mbstate_t> *
>>          converter(
>>             &std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
>>              ( loc() ) );
>>
>> which cals 'loc' before 'main' is called, and gives the same problem.
>
> Grrr.... Sorry. Fixed in CVS.

Thanks, this makes the error go away. (Since I don't use wpath, the
converter is not used now, so there's no exception at all).

- Volodya

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost