diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h b/lldb/include/lldb/Breakpoint/Breakpoint.h --- a/lldb/include/lldb/Breakpoint/Breakpoint.h +++ b/lldb/include/lldb/Breakpoint/Breakpoint.h @@ -382,7 +382,10 @@ /// \param[in] is_synchronous /// If \b true the callback will be run on the private event thread /// before the stop event gets reported. If false, the callback will get - /// handled on the public event thread after the stop has been posted. + /// handled on the public event thread while the stop event is being + /// pulled off the event queue. + /// Note: synchronous callbacks cannot cause the target to run, in + /// particular, they should not try to run the expression evaluator. void SetCallback(BreakpointHitCallback callback, void *baton, bool is_synchronous = false); diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp --- a/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp @@ -306,7 +306,7 @@ .CreateBreakpoint(symbol_address, internal, hardware) .get(); breakpoint->SetCallback(InstrumentationRuntimeASan::NotifyBreakpointHit, this, - true); + false); breakpoint->SetBreakpointKind("address-sanitizer-report"); SetBreakpointID(breakpoint->GetID()); diff --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp --- a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp @@ -215,7 +215,7 @@ /*hardware=*/false) .get(); breakpoint->SetCallback( - InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit, this, true); + InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit, this, false); breakpoint->SetBreakpointKind("main-thread-checker-report"); SetBreakpointID(breakpoint->GetID()); diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp --- a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp @@ -922,7 +922,7 @@ .CreateBreakpoint(symbol_address, internal, hardware) .get(); breakpoint->SetCallback(InstrumentationRuntimeTSan::NotifyBreakpointHit, this, - true); + false); breakpoint->SetBreakpointKind("thread-sanitizer-report"); SetBreakpointID(breakpoint->GetID()); diff --git a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp --- a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp @@ -276,7 +276,7 @@ /*hardware=*/false) .get(); breakpoint->SetCallback(InstrumentationRuntimeUBSan::NotifyBreakpointHit, - this, true); + this, false); breakpoint->SetBreakpointKind("undefined-behavior-sanitizer-report"); SetBreakpointID(breakpoint->GetID()); diff --git a/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py b/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py --- a/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py +++ b/lldb/test/API/functionalities/ubsan/basic/TestUbsanBasic.py @@ -86,4 +86,9 @@ self.assertEqual(os.path.basename(data["filename"]), "main.c") self.assertEqual(data["line"], self.line_align) - self.runCmd("continue") + for count in range(0,8): + process.Continue() + stop_reason = thread.GetStopReason() + self.assertEqual(stop_reason, lldb.eStopReasonInstrumentation, + "Round {0} wasn't instrumentation".format(count)) + diff --git a/lldb/test/API/functionalities/ubsan/basic/main.c b/lldb/test/API/functionalities/ubsan/basic/main.c --- a/lldb/test/API/functionalities/ubsan/basic/main.c +++ b/lldb/test/API/functionalities/ubsan/basic/main.c @@ -1,4 +1,16 @@ int main() { int data[4]; - return *(int *)(((char *)&data[0]) + 2); // align line + int result = *(int *)(((char *)&data[0]) + 2); // align line + + int *p = data + 5; // Index 5 out of bounds for type 'int [4]' + *p = data + 5; + *p = data + 5; + *p = data + 5; + *p = data + 5; + *p = data + 5; + *p = data + 5; + *p = data + 5; + *p = data + 5; + + return 0; }