-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lldb can't run static initializers on AArch64 Ubuntu and FreeBSD #43398
Comments
It probably also doesn't help that LLDB's error message here is pretty much useless. |
It would probably help with debugging if you could add a Then rerun the test and attach the |
Thanks for having a look! I can't attach the log because it's too big, but you can download it from here: |
I am not sure where the error in that log is but it seems like it is not in the expression parser but something is going on when we run the ThreadPlan. CC'ing Jim because he knows that code. I added more logging to the function in 4a6d03a so if you rerun the test with the log command we should see if something is going on when we actually try to find the static initialisers (even though I doubt this is happening but instead running them just fails). https://reviews.llvm.org/D70433 could improve the error message in these situations, so maybe then you get a more useful error. |
The interesting bit in the log related to "ThreadPlans" is: intern-state 0xffff7c356560 'Communication::SyncronizeWithReadThread' Listener::FindNextEventInternal(broadcaster=(nil), broadcaster_names=(nil)[0], event_type_mask=0x00000000, remove=1) event 0xffff840008d0 The expression evaluation crashed running some part of the expression (at 0x0000ffffb7ff809c) It looks like that code belongs to .text._ZN4Foo2C2Ev. We usually print the disassembly of the expression we're injecting in the expr log but I didn't see that there. |
New log (with D70433 applied): https://drive.google.com/file/d/1BCvKbg_kuVQw6wDpmh1xGvipiV3ckwtE/view?usp=sharing |
Is there any way I can get it? I can run lldb manually if needed, potentially with other patches on top. |
Maybe we only print that with verbose logging? You could try by changing the added line to:
and then upload the expr.log file. You could also check what exact part of the expression causes us to fail. Try changing the line You also have to remove all lines after that line otherwise the following checks will fail. |
It's option 1: runCmd: expr -p -- struct Foo { Foo() { } }; Foo f; |
I think we had a bug where calling constructors sometimes doesn't work on some platforms/configurations. Are you using LLD by chance to link the test binaries for LLDB (i.e. LLD is your default linker or you enabled the LLD project in your LLVM build setup)? Also does it work if you split up the expression like that? self.expect("expr -p -- struct Foo { Foo() { inc_counter(); } };") (This way we call the constructor like a normal expression and not in as a static initialiser). |
Yes, LLD is in LLVM_ENABLE_PROJECTS.
Yes, this works. |
Maybe the call to
|
Nope, still errors out :( |
I don't remember now whether the static initializers get run with the expression or as a separate pass, but if it is the former, it might be worth trying to run the expression as: (lldb) expr -u 0 -- In the case of normal expressions, if the expression crashes this will leave lldb stopped at the point of the crash, and you can actually poke around and see why more clearly. |
We run them separately here from what I understand: llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Line 1367 in 96d814a
|
Most importantly we create a fresh set of options to run the function, so we're going to ignore breakpoints and clean up on crashes. There are a bunch of these utility function calls that happen under the covers and it's not easy to ensure that stopping in for a breakpoint or crash and handing back control to the user would actually work... We get into the same situation when something causes the Object Description functions to crash, where it would be really useful to stop at the crash. In this case, it would be interesting to try copying over the options of the containing expression, let it crash, and see what happens. It might work, or at least well enough to get a backtrace out. If that doesn't work we could always take and log a backtrace when these expressions crash (maybe only when the "expr" log is turned on). That also might show more information and wouldn't be hard to do. |
Sorry about the delay. I tried to run It doesn't seem to do anything, it "just runs", doesn't print anything, doesn't crash, nothing. I can still step or do other things afterwards. Am I doing something wrong here? |
Sorry, I was being a little unclear in my back and forth with Raphael. The problem is that this is not crashing in the main expression evaluation, but in a separate expression evaluation that happens under the covers in lldb. That separate expression evaluation does not use the options passed to the "expr" command that triggered it. So you would have to change the lldb code Raphael pointed to to actually get the expression not to automatically unwind when it crashes. So it is entirely expected in the current code that passing "-u 0" has no effect on your crash. If you want to play around with this yourself, try modifying the code Raphael cited below line 1360, and just do: options->SetUnwindOnError(true); That will force lldb to stop when this crash is encountered. I don't actually know whether lldb will recover from stopping there gracefully, but it might... |
I wonder if #49407 is related, as it also has some SIGILL. In any case, FreeBSD seems to suffer from this issue as well. |
#92245 fixed this on Linux, FreeBSD maybe too but needs confirming. |
PR llvm#92245 fixed these tests on Linux. They likely work on FreeBSD too but leaving the xfail for that so it can be confirmed later. Also updated a bugzilla link to one that redirects to Github issues. Relates to issues llvm#43398 and llvm#48751.
Extended Description
TestStaticInitializers.py fails on AArch64 Linux for dwarf and dwo with:
runCmd: expr -p -- struct Foo { Foo() { inc_counter(); } }; Foo f;
runCmd failed!
error: couldn't run static initializers: couldn't run static initializer:
FAILURE
FAIL: LLDB (/home/diana.picus/llvm-envs/lldb/build/bin/clang-10-aarch64) :: test_dwo (TestStaticInitializers.StaticInitializers)
<bound method SBProcess.Kill of <lldb.SBProcess; proxy of <Swig Object of type 'lldb::SBProcess *' at 0xffff9f513d20> >>: success
The text was updated successfully, but these errors were encountered: