This is an archive of the discontinued LLVM Phabricator instance.

[lldb/test] Fix TestProgressReporting.py race issue with the event listener
ClosedPublic

Authored by mib on Feb 21 2022, 2:33 PM.

Details

Summary

This patch is a follow-up of D120100 to address some feedbacks from
@labath.

This should mainly fix the race issue with the even listener by moving
the listener setup to the main thread.

This also changes the SBDebugger::GetProgressFromEvent SWIG binding
arguments to be output only, so the user don't have to provide them.

Finally, this updates the test to check it the out arguments are returned
in a tuple and re-enables the test on all platforms.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>

Diff Detail

Event Timeline

mib created this revision.Feb 21 2022, 2:33 PM
mib requested review of this revision.Feb 21 2022, 2:33 PM
mib updated this revision to Diff 410449.Feb 21 2022, 10:24 PM
labath accepted this revision.Feb 22 2022, 3:41 AM
This revision is now accepted and ready to land.Feb 22 2022, 3:41 AM
mib updated this revision to Diff 410973.Feb 23 2022, 4:48 PM
mib edited the summary of this revision. (Show Details)

Make the interface binding arguments OUTPUT only.
Re-enable test on all platforms.

This revision was landed with ongoing or failed builds.Feb 23 2022, 4:49 PM
This revision was automatically updated to reflect the committed changes.

This fails under MSAN:

==3096==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f0e7899ce18  (/build/work/73ffa3b6f1cbc2218b7b71e21a3dd1e2e53b/google3/runfiles/google3/third_party/py/lldb/dotest_wrapper.par/@0x3a0b9000+0x2e3e18) (BuildId: 4c3940d9ff00226e685dcfb93f4b4753)
    #1 0x7f0e7898fcc8  (/build/work/73ffa3b6f1cbc2218b7b71e21a3dd1e2e53b/google3/runfiles/google3/third_party/py/lldb/dotest_wrapper.par/@0x3a0b9000+0x2d6cc8) (BuildId: 4c3940d9ff00226e685dcfb93f4b4753)
    #2 0x7f0e78973001  (/build/work/73ffa3b6f1cbc2218b7b71e21a3dd1e2e53b/google3/runfiles/google3/third_party/py/lldb/dotest_wrapper.par/@0x3a0b9000+0x2ba001) (BuildId: 4c3940d9ff00226e685dcfb93f4b4753)
    #3 0x7f0e78cd1f10  (/build/work/73ffa3b6f1cbc2218b7b71e21a3dd1e2e53b/google3/runfiles/google3/third_party/py/lldb/dotest_wrapper.par/@0x3a0b9000+0x618f10) (BuildId: 4c3940d9ff00226e685dcfb93f4b4753)
    #4 0x558eaf3ecc70 in cfunction_call_varargs third_party/python_runtime/v3_7/Objects/call.c:770:18
    #5 0x558eaf3ecc70 in PyCFunction_Call third_party/python_runtime/v3_7/Objects/call.c:786:16
    #6 0x558eaf685ff8 in do_call_core third_party/python_runtime/v3_7/Python/ceval.c:4641:9
    #7 0x558eaf685ff8 in _PyEval_EvalFrameDefault third_party/python_runtime/v3_7/Python/ceval.c:3191:22
    #8 0x558eaf6a0691 in PyEval_EvalFrameEx third_party/python_runtime/v3_7/Python/ceval.c:547:12
    #9 0x558eaf6a0691 in _PyEval_EvalCodeWithName third_party/python_runtime/v3_7/Python/ceval.c:3930:14
    #10 0x558eaf3ebaa3 in _PyFunction_FastCallKeywords third_party/python_runtime/v3_7/Objects/call.c:433:12
    #11 0x558eaf69db2d in call_function third_party/python_runtime/v3_7/Python/ceval.c:4616:17
    #12 0x558eaf685844 in _PyEval_EvalFrameDefault third_party/python_runtime/v3_7/Python/ceval.c:3093:23
    #13 0x558eaf67d594 in PyEval_EvalFrameEx third_party/python_runtime/v3_7/Python/ceval.c:547:12
    #14 0x558eaf3ed230 in function_code_fastcall third_party/python_runtime/v3_7/Objects/call.c:283:14
    #15 0x558eaf3ea160 in _PyFunction_FastCallDict third_party/python_runtime/v3_7/Objects/call.c
    #16 0x558eaf3e99a4 in _PyObject_FastCallDict third_party/python_runtime/v3_7/Objects/call.c:98:16
    #17 0x558eaf3ef739 in _PyObject_Call_Prepend third_party/python_runtime/v3_7/Objects/call.c:906:14
    #18 0x558eaf3f462b in method_call third_party/python_runtime/v3_7/Objects/classobject.c:309:12
    #19 0x558eaf3ec51d in PyObject_Call third_party/python_runtime/v3_7/Objects/call.c:245:18
    #20 0x558eaf685d63 in do_call_core third_party/python_runtime/v3_7/Python/ceval.c:4645:16
    #21 0x558eaf685d63 in _PyEval_EvalFrameDefault third_party/python_runtime/v3_7/Python/ceval.c:3191:22
    #22 0x558eaf67d594 in PyEval_EvalFrameEx third_party/python_runtime/v3_7/Python/ceval.c:547:12
    #23 0x558eaf3ed230 in function_code_fastcall third_party/python_runtime/v3_7/Objects/call.c:283:14
    #24 0x558eaf3ebb23 in _PyFunction_FastCallKeywords third_party/python_runtime/v3_7/Objects/call.c
    #25 0x558eaf69db2d in call_function third_party/python_runtime/v3_7/Python/ceval.c:4616:17
    #26 0x558eaf685808 in _PyEval_EvalFrameDefault third_party/python_runtime/v3_7/Python/ceval.c:3110:23
    #27 0x558eaf67d594 in PyEval_EvalFrameEx third_party/python_runtime/v3_7/Python/ceval.c:547:12
    #28 0x558eaf3ed230 in function_code_fastcall third_party/python_runtime/v3_7/Objects/call.c:283:14
    #29 0x558eaf3ebb23 in _PyFunction_FastCallKeywords third_party/python_runtime/v3_7/Objects/call.c
    #30 0x558eaf69db2d in call_function third_party/python_runtime/v3_7/Python/ceval.c:4616:17
    #31 0x558eaf685808 in _PyEval_EvalFrameDefault third_party/python_runtime/v3_7/Python/ceval.c:3110:23
    #32 0x558eaf67d594 in PyEval_EvalFrameEx third_party/python_runtime/v3_7/Python/ceval.c:547:12
    #33 0x558eaf3ed230 in function_code_fastcall third_party/python_runtime/v3_7/Objects/call.c:283:14
    #34 0x558eaf3ea160 in _PyFunction_FastCallDict third_party/python_runtime/v3_7/Objects/call.c
    #35 0x558eaf3e99a4 in _PyObject_FastCallDict third_party/python_runtime/v3_7/Objects/call.c:98:16
    #36 0x558eaf3ef739 in _PyObject_Call_Prepend third_party/python_runtime/v3_7/Objects/call.c:906:14
    #37 0x558eaf3f462b in method_call third_party/python_runtime/v3_7/Objects/classobject.c:309:12
    #38 0x558eaf3ec51d in PyObject_Call third_party/python_runtime/v3_7/Objects/call.c:245:18
    #39 0x558eaecfdc9a in t_bootstrap third_party/python_runtime/v3_7/Modules/_threadmodule.c:994:11
    #40 0x558eaf77ac94 in pythread_wrapper third_party/python_runtime/v3_7/Python/thread_pthread.h:174:5
    #41 0x7f0e7bf0eb54 in start_thread (/usr/grte/v5/lib64/libpthread.so.0+0xbb54) (BuildId: 64752de50ebd1a108f4b3f8d0d7e1a13)
    #42 0x7f0e7be43f7e in clone (/usr/grte/v5/lib64/libc.so.6+0x13cf7e) (BuildId: 7cfed7708e5ab7fcb286b373de21ee76)

I'll revert.

The backtrace is pretty much useless, but what is happening is that the LLDB_INSTRUMENT_VA macro inside SBDebugger::GetProgressFromEvent is trying to log the uninitialized output variable, which angers the gods of sanitation.

I'm not entirely sure what's the best fix here. @JDevlieghere, what do you think? Can we just remove the output arguments from the LLDB_INSTRUMENT_VA invocation (given how logging their entry values is pretty useless)?

The backtrace is pretty much useless

Yes, sorry, that's all I had. Just added some evidence.

I'm not entirely sure what's the best fix here. @JDevlieghere, what do you think? Can we just remove the output arguments from the LLDB_INSTRUMENT_VA invocation (given how logging their entry values is pretty useless)?

Yup, the way I dealt with that for the reproducers was initialize them before the macro, but no point in doing that purely for logging. Let's just remove the macro.

I'll need to think of a way to avoid lldb-instr putting it back. It will ignore functions that start with a macro, so maybe we can add a NOOP macro "LLDB_NO_INSTRUMENT" or something?

mib added a comment.Feb 25 2022, 10:41 AM

I'm not entirely sure what's the best fix here. @JDevlieghere, what do you think? Can we just remove the output arguments from the LLDB_INSTRUMENT_VA invocation (given how logging their entry values is pretty useless)?

Yup, the way I dealt with that for the reproducers was initialize them before the macro, but no point in doing that purely for logging. Let's just remove the macro.

I'll need to think of a way to avoid lldb-instr putting it back. It will ignore functions that start with a macro, so maybe we can add a NOOP macro "LLDB_NO_INSTRUMENT" or something?

Will lldb-instr try to override the macro if not all the function arguments are passed to the LLDB_INSTRUMENT_VA invocation ? If this is not the case, it should be fine for SBDebugger::GetProgressFromEvent since it still takes an SBEvent argument, that will remain in the LLDB_INSTRUMENT_VA invocation.

I'm not entirely sure what's the best fix here. @JDevlieghere, what do you think? Can we just remove the output arguments from the LLDB_INSTRUMENT_VA invocation (given how logging their entry values is pretty useless)?

Yup, the way I dealt with that for the reproducers was initialize them before the macro, but no point in doing that purely for logging. Let's just remove the macro.

I'll need to think of a way to avoid lldb-instr putting it back. It will ignore functions that start with a macro, so maybe we can add a NOOP macro "LLDB_NO_INSTRUMENT" or something?

I thought we could just replace LLDB_INSTRUMENT_VA(event, progress_id, completed, total, is_debugger_specific); with LLDB_INSTRUMENT_VA(event);

Is that not sufficient to dissuade the tool?

Yup, that works too