Repository navigation
Use the standard library's numeric facets in the global locale - #734
Open
CoffeeFlux wants to merge 1 commit into
Open
CoffeeFlux wants to merge 1 commit into
CoffeeFlux wants to merge 1 commit into
Conversation
Boost.Locale's num_parse forwards to std::num_get::do_get, so the binary gets its own copy of num_get::__do_get_floating_point from the SDK's libc++ headers. Since LLVM 19 that copy allocates a 28-character buffer and has the system libc++'s __num_get<char>::__stage2_float_prep fill it, but the libc++ in older macOS releases writes 32 characters. Parsing any floating-point number then aborts with a stack buffer overflow, which crashes 3.5.0 on startup on macOS 13 while reading the default config. Take the numeric category from the classic locale instead. Nothing uses Boost.Locale's locale-aware number formatting, and its ICU backend doesn't supply its own numpunct, so parsing and formatting behave the same. Fixes TypesettingTools#733. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #733: 3.5.0 aborts with "stack buffer overflow" at startup on macOS 13 while parsing the default config.
Cause
This is a libc++ bug that breaks apps built for older macOS:
InitLocale()makes a Boost.Locale locale global. Its number parser,num_parse, forwards tostd::num_get::do_get, so the app gets its own copy ofnum_get::__do_get_floating_point, compiled from the SDK's libc++ headers.__num_get<char>::__stage2_float_prepfill it.This matches the crash log:
__input_arithmetic<double>in the system libc++ calls__do_get_floating_point<double>in the app binary, which ends in__stack_chk_fail. In the static release build,libboost_locale.ais the only place__do_get_floating_pointis defined.Fix
Take the numeric category of the global locale from the classic locale instead, so number parsing and formatting run entirely inside the system libc++.
This shouldn't change behavior:
as::manipulators orformat).numpunct, so the decimal point and grouping were already the classic locale's.Testing
lagi_util.init_locale_uses_std_numeric_facets, which checks that the globalnum_get<char>andnum_put<char>are the standard ones. Without the fix it fails withboost::locale::impl_icu::num_parse<char>.InitLocale(), so the JSON, option and VFR tests now run with these facets.🤖 Generated with Claude Code