Skip to content

LLDB reports empty std::vector when reproducer is compiled with -D_GLIBCXX_DEBUG #60841

Closed
@tbaederr

Description

@tbaederr

Using this code:

#include <cassert>
#include <vector>

int main() {
  std::vector<int> V;
  V.push_back(12);
  assert(false);
  return 0;
}

shows the correct vector size in lldb when compiled with clang++ ./vec.cpp -g -std=c++20:

~ » lldb ./a.out -o run -o ' up 5' -o 'p V' -o q
(lldb) target create "./a.out"
Current executable set to '/home/tbaeder/a.out' (x86_64).
(lldb) run
a.out: ./vec.cpp:7: int main(): Assertion `false' failed.
Process 1492018 stopped
* thread #1, name = 'a.out', stop reason = signal SIGABRT
    frame #0: 0x00007ffff788ebec libc.so.6`__pthread_kill_implementation + 284
libc.so.6`__pthread_kill_implementation:
->  0x7ffff788ebec <+284>: movl   %eax, %ebp
    0x7ffff788ebee <+286>: negl   %ebp
    0x7ffff788ebf0 <+288>: cmpl   $0xfffff000, %eax         ; imm = 0xFFFFF000
    0x7ffff788ebf5 <+293>: movl   $0x0, %eax
Process 1492018 launched: '/home/tbaeder/a.out' (x86_64)
(lldb)  up 5
frame #5: 0x000000000040122d a.out`main at vec.cpp:7:3
   4   	int main() {
   5   	  std::vector<int> V;
   6   	  V.push_back(12);
-> 7   	  assert(false);
   8   	  return 0;
   9   	}
(lldb) p V
(std::vector<int, std::allocator<int> >) $0 = size=1 {
  [0] = 12
}
(lldb) q

But when compiled with clang++ ./vec.cpp -g -std=c++20 -D_GLIBCXX_DEBUG:

~ » lldb ./a.out -o run -o ' up 5' -o 'p V' -o q
(lldb) target create "./a.out"
Current executable set to '/home/tbaeder/a.out' (x86_64).
(lldb) run
a.out: ./vec.cpp:7: int main(): Assertion `false' failed.
Process 1492120 stopped
* thread #1, name = 'a.out', stop reason = signal SIGABRT
    frame #0: 0x00007ffff788ebec libc.so.6`__pthread_kill_implementation + 284
libc.so.6`__pthread_kill_implementation:
->  0x7ffff788ebec <+284>: movl   %eax, %ebp
    0x7ffff788ebee <+286>: negl   %ebp
    0x7ffff788ebf0 <+288>: cmpl   $0xfffff000, %eax         ; imm = 0xFFFFF000
    0x7ffff788ebf5 <+293>: movl   $0x0, %eax
Process 1492120 launched: '/home/tbaeder/a.out' (x86_64)
(lldb)  up 5
frame #5: 0x00000000004012bd a.out`main at vec.cpp:7:3
   4   	int main() {
   5   	  std::vector<int> V;
   6   	  V.push_back(12);
-> 7   	  assert(false);
   8   	  return 0;
   9   	}
(lldb) p V
(std::vector<int, std::allocator<int> >) $0 = size=0 {}
(lldb) q

... the size is reported as 0, which is clearly wrong.

Using lldb 15.0.7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    libstdc++GNU libstdc++ C++ standard librarylldb

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions