Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opt-out of std::locale via cmake -DENABLE_LOCALE=N #134

Closed
wants to merge 1 commit into from

Conversation

nigels-com
Copy link

Thanks for muparser, it's getting the job done nicely.

I don't have at hand the details of why we needed to opt-out of std::locale, but this is the main divergence we have.

@beltoforion
Copy link
Owner

I'm sorry but "I don't know why we need this" is not a compelling reason for a merge. I don't see a use in the change and it is altering the API by removing the following functions:

parser.SetDecSep(',');
parser.SetThousandsSep('.');

@nigels-com
Copy link
Author

Fair enough! A somewhat less vague rationale, looking at some slack threads from a year ago.

A colleague was having a crash at shutdown on Ubuntu 20.04 (most likely). valgrind suggested that was to do with static object order of construction and destruction. In particular: mu::ParserBase::s_locale

Because it's static and opaque std::locale the fix (or workaround perhaps) is this change to opt-out of locale support.

@nigels-com
Copy link
Author

Whether that's technically a bug in the relevant plugin architecture, dlopen stuff, or somehow because we're statically linking muparser, not clear. I'd be inclined to avoid having static std::locale (ideally).

@nigels-com
Copy link
Author

A somewhat redacted valgrind fragment:

==121635== Invalid read of size 4
==121635==    at 0x4D9AB05: std::locale::~locale() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28)
==121635==    by 0x50728A6: __run_exit_handlers (exit.c:108)
==121635==    by 0x5072A5F: exit (exit.c:139)
==121635==    by 0x5050089: (below main) (libc-start.c:342)
==121635==  Address 0x54905d0 is 0 bytes inside a block of size 40 free'd
==121635==    at 0x4A3BE99: operator delete(void*) (vg_replace_malloc.c:923)
==121635==    by 0x50728A6: __run_exit_handlers (exit.c:108)
==121635==    by 0x5072A5F: exit (exit.c:139)
==121635==    by 0x5050089: (below main) (libc-start.c:342)
==121635==  Block was alloc'd at
==121635==    at 0x4A397B3: operator new(unsigned long) (vg_replace_malloc.c:422)
==121635==    by 0x2AF3C0: std::locale::locale<mu::ParserBase::change_dec_sep<char> >(std::locale const&, mu::ParserBase::change_dec_sep<char>*) (in ...)
==121635==    by 0x167C586D: _GLOBAL__sub_I_muParserBase.cpp (in ... /fooplugin.so)
==121635==    by 0x4011B99: call_init.part.0 (dl-init.c:72)
==121635==    by 0x4011CA0: call_init (dl-init.c:30)
==121635==    by 0x4011CA0: _dl_init (dl-init.c:119)
==121635==    by 0x518C984: _dl_catch_exception (dl-error-skeleton.c:182)
==121635==    by 0x40160CE: dl_open_worker (dl-open.c:758)
==121635==    by 0x518C927: _dl_catch_exception (dl-error-skeleton.c:208)
==121635==    by 0x4015609: _dl_open (dl-open.c:837)
==121635==    by 0x545E34B: dlopen_doit (dlopen.c:66)
==121635==    by 0x518C927: _dl_catch_exception (dl-error-skeleton.c:208)
==121635==    by 0x518C9F2: _dl_catch_error (dl-error-skeleton.c:227)
==121635==    by 0x545EB58: _dlerror_run (dlerror.c:170)
==121635==    by 0x545E3D9: dlopen@@GLIBC_2.2.5 (dlopen.c:87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants