boostorg / boostorg/boost

[b2] std::length_error crash when empty string is passed to var_defines on LoongArch

Open
#1,141 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
8.6k
Forks
1.9k
Avg merge
39m
Merged PRs (30d)
2

Description

Environment:
- Boost: 1.91.0
- Arch: LoongArch (loongarch64)
- Compiler: GCC 15.2.1

Problem:
b2 crashes with std::length_error on basic commands like `./b2 --show-libraries`.

Backtrace:
```
#11 var_defines (variable.cpp:84)
#12 guarded_main (jam.cpp:527)
#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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.