Skip to content

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

@setarcos

Description

@setarcos

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions