Opened 6 years ago

Closed 6 years ago

#14780 closed defect (fixed)

Crash during startup C++ locale setting wxOSX Cocoa

Reported by: arondobos Owned by:
Priority: high Milestone: 2.9.5
Component: wxOSX Version: stable-latest
Keywords: Cc: memelink.akker@…
Blocked By: Blocking:
Patch: no


The current SVN version of wxWidgets crashes on startup with the following trace:

This was running the webview sample (unchanged) after compiling the library.

0 libSystem.B.dylib 0x00007fff8667a5d6 kill + 10
1 libSystem.B.dylib 0x00007fff8671acde abort + 83
2 libstdc++.6.dylib 0x00007fff825be5d2
tcf_0 + 0
3 libobjc.A.dylib 0x00007fff80e4cd3d _objc_terminate + 120
4 libstdc++.6.dylib 0x00007fff825bcae1 cxxabiv1::terminate(void (*)()) + 11
5 libstdc++.6.dylib 0x00007fff825bcb16 cxxabiv1::unexpected(void (*)()) + 0
6 libstdc++.6.dylib 0x00007fff825bcbfc gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*) + 0
7 libstdc++.6.dylib 0x00007fff82578bd8 std::
throw_runtime_error(char const*) + 127
8 libstdc++.6.dylib 0x00007fff825b6c6b std::locale::facet::_S_create_c_locale(int*&, char const*, int*) + 45
9 libstdc++.6.dylib 0x00007fff8257bb10 std::locale::_Impl::_Impl(char const*, unsigned long) + 86
10 libstdc++.6.dylib 0x00007fff8257c832 std::locale::locale(char const*) + 1112
11 org.wxwindows.. 0x000000010021c7b1 wxAppTraitsBase::SetLocale() + 49
12 org.wxwindows.. 0x000000010021d322 wxAppConsoleBase::Initialize(int&, wchar_t) + 18
13 org.wxwindows.. 0x00000001003085f1 wxAppConsole::Initialize(int&, wchar_t
) + 17
14 org.wxwindows.. 0x0000000100125181 wxAppBase::Initialize(int&, wchar_t) + 17
15 org.wxwindows.. 0x00000001000bbba2 wxApp::Initialize(int&, wchar_t
) + 226
16 org.wxwindows.. 0x000000010028baf2 wxEntryStart(int&, wchar_t) + 130
17 org.wxwindows.. 0x000000010028c03c wxInitialize(int, wchar_t
) + 108
18 org.wxwindows.. 0x000000010028c09b wxEntry(int&, wchar_t) + 27
19 org.wxwindows.. 0x0000000100038ae4 main + 20
20 org.wxwindows.. 0x0000000100038604 start + 52

I think this is related to #72719.

I compiled SVN 72780 using

./configure --prefix=/Users/adobos/local/wx3-svn --disable-shared --enable-stl --with-cocoa --with-libjpeg=builtin --with-libpng=builtin --with-regex=builtin --with-libtiff=builtin --with-zlib=builtin --with-expat=builtin

Change History (5)

comment:1 Changed 6 years ago by arondobos

FYI: I'm on OSX Snow Leopard 10.6.7 with gcc 4.2.1 apple build 5646

comment:2 Changed 6 years ago by Stephan66

  • Cc memelink.akker@… added

No crash of the webview sample with SVN 72811 on Windows XP SP3 with IE8 trident backend of webview.

compiled using gcc 4.6.2 (mingw):

../configure --prefix=/d/wxWidgets/mswr/ LDFLAGS="-static-libgcc -static-libstdc++" --enable-stl --disable-debug --disable-shared --enable-unicode --with-msw --disable-monolithic --disable-compat26

Because of the --enable-stl I am sure that std::locale is set here as well in wxAppTraitsBase::SetLocale()

comment:3 Changed 6 years ago by Stephan66

No crash of the webview sample with SVN 72811 on OpenSuSE 12.2 (32-bit)

webview backend: libwebkitgtk version 1.8.1 (= stock openSuSE 12.2)

compiled using gcc (SUSE Linux) 4.7.1 20120723 [gcc-4_7-branch revision 189773] (=stock openSuSE 12.2)

../configure --enable-stl --enable-unicode --disable-debug --disable-shared --disable-monolithic --disable-compat26

This really seems like something wxOSX-Cocoa specific, or perhaps webkit version specific.

comment:4 Changed 6 years ago by vadz

  • Status changed from new to confirmed

I can confirm the crash as soon as the locale is set to something other than "C". E.g. LC_ALL=fr_FR.UTF-8 ./samples/webview/ crashes. This only happens in wxUSE_STL==1 build as std::locale is only used there.

Unfortunately exactly the same crash happens in this program:

#include <iostream>

using namespace std;

int main()

    cout << "Number is " << 123.45 << "\n";

so it looks like another awful OS X bug :-( And to make the matters worse I see it under OS X 10.8 too.

And we're not the only ones to see it. Unfortunately this doesn't help at all, we now have to decide whether we should stop doing this under OS X or stop doing it everywhere because this makes the behaviour inconsistent.

And I have no idea how are people supposed to use C++ streams under OS X :-(

comment:5 Changed 6 years ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [72951]) Don't call setlocale("") on startup by default any longer.

This undoes the changes of r44773 because calling setlocale() resulted in C
locale being set differently from C++ locale which was confusing and led to
huge slowdowns in any code using std::stream with at least MinGW. And setting
the C++ locale to be the same, as r72719 tried to do, doesn't seem to be
practical as it results in immediate crashes under OS X and MinGW when used
under XP.

Do provide wxApp::SetCLocale() helper to explicitly do what was previously
done implicitly, even though currently it is a trivial wrapper for setlocale()
and we don't even need to call gtk_set_locale() as it has never done anything
else and is deprecated since GTK+ 2.24.

Closes #14780.

Note: See TracTickets for help on using tickets.