You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[b2] std::length_error crash when empty string is passed to var_defines on LoongArch #786
Problem:
b2 crashes with std::length_error on basic commands like ./b2 --show-libraries.
Backtrace:
boostorg/boost#11 var_defines (variable.cpp:84)
boostorg/boost#12 guarded_main (jam.cpp:527)
boostorg/boost#13 main (jam.cpp:694)
Root cause:
In variable.cpp:84, when an empty string is passed to var_defines(), string_view::find('=') returns npos, causing var to be constructed with npos as length. Then std::string{var.begin(), var.end()} tries to allocate 18446744073709551615 bytes -> length_error.
Activity
iv-m commentedon Jul 1, 2026
I've just stumbled upon this on my loongarch64 machine. Trivial fix like this seems to help:
But I'm not sure if this is the right thing to do, or why this empty string is passed here in the first place.
iv-m commentedon Jul 1, 2026
BTW this issue probably should be moved to https://github.com/boostorg/build/issues.
iv-m commentedon Aug 14, 2026
This might be fixed in 708353c
pdimov commentedon Oct 28, 2026
I can move this issue to boostorg/build, but the upstream repository of B2 is https://github.com/bfgroup/b2, and I can't move it there. :-)
grafikrobot commentedon Oct 28, 2026
Yes, certain that is the fix. And you can try it out by using a more recent b2 (which you can do with any Boost version).