aeubanks added a comment.

In D137983#3930973 <https://reviews.llvm.org/D137983#3930973>, @labath wrote:

> We have tests for shared libraries (grep for DYLIB_C(XX)_SOURCES)), but it's 
> easier to reproduce this problem by compiling one CU with -g0 -- see inline 
> comment. (If you are creating an "API" test for this, beware that their 
> default is to build everything with -fstandalone-debug, and you'll need to 
> explicitly change that (see LIMIT_DEBUG_INFO_FLAGS))

`lldb/test/API/lang/cpp/incomplete-types/` looks like exactly what I want, I've 
added a test based on that (and verified that lldb crashes in that test without 
the source change)

> This behavior (bug) is triggered by the `FrontEndWantsDereference` formatter 
> flag, which is why it manifests itself for (libc++) vector and friends. The 
> ObjC formatters don't set that flag so they should be safe. The libstdc++ 
> formatters don't set it either. Furthermore there doesn't seem to be a way to 
> set this flag by the user, so it is not possible to create a 
> libc++-independent reproducer (which is what I was going to suggest).
>
> I've been looking for a better way to fix this today (sorry about the delay), 
> but I haven't figured out anything better. There is this fundamental 
> recursion between the pretty printer (which wants to dereference a value) and 
> the dereferencing code (which wants to know if it has a pretty printer -- so 
> it can avoid dereferencing). Just removing the `HasSyntheticValue()`fixed the 
> bug for me -- but then we were able to "dereference" incomplete structs. It's 
> possible we may be able to allow the dereference to succeed here, but then 
> refuse to print the value somewhere down the line. I would like to hear what 
> @jingham things about all this.

Thanks for the investigation!
Actually some libstdc++ formatters do also set `FrontEndWantsDereference`, so 
this is reproable with

  $ cat /tmp/main.cc
  #include <set>
  
  void f(std::set<int>& v);
  
  int main() {
          std::set<int> v;
          f(v);
  }
  $ cat /tmp/a.cc
  #include <set>
  
  void f(std::set<int>& v) {
          // break
  }
  $ bin/clang++ -g0 /tmp/main.cc -o /tmp/main.o  -c && bin/clang++ -g /tmp/a.cc 
-o /tmp/a.o  -c && bin/clang++ /tmp/a.o /tmp/main.o -o /tmp/a
  $ bin/lldb /tmp/a -b -o 'br set -n f'  -o run

with and without `-stdlib=libc++`

maybe a more targeted solution would be to change the added condition to when 
`FrontEndWantsDereference` is set, but that's more annoying to thread through 
the code. I think this should be ok as a temporary workaround if we don't have 
a proper fix soonish?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137983/new/

https://reviews.llvm.org/D137983

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to