llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.45k stars 11.76k forks source link

Segfault when evaluating STL expression #38848

Open ldionne opened 5 years ago

ldionne commented 5 years ago
Bugzilla Link 39500
Version unspecified
OS All

Extended Description

When evaluating some STL expression, lldb segfaults. This only seems to happen with a recent Clang and LLDB, which may be related to the removal of always_inline from libc++ shipped with recent Clangs.

This bug is a reduction of the STL-related failure that started happening in http://green.lab.llvm.org/green/job/lldb-cmake/11896.

Here's the reproduction (with Trunk Clang and LLDB):

#!/bin/sh

cat > t.cpp <<EOF
#include <cstdio>
#include <map>
#include <string>
int main() {
    std::string hello_world = "Hello World!";
    std::map<std::string, int> associative_array;
    associative_array[hello_world] = 1;
    associative_array.count(hello_world);
    std::printf("before returning....\n"); // Set break point at this line.
}
EOF

clang++ t.cpp -O0 -g
lldb a.out

Then, from within lldb:

breakpoint set -l 9
run
expr associative_array.count(hello_world)
expr associative_array.count(hello_world)

The evaluation works the first time around, but fails the second time around with a segfault.

llvmbot commented 5 years ago

Shafik is the best person to look at this.