[libunwind] 66632e8 - [libunwind] [SEH] Handle ExceptionContinueExecution in forced unwinding

Martin Storsjö via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 10 14:03:44 PDT 2023


Author: Martin Storsjö
Date: 2023-04-11T00:00:30+03:00
New Revision: 66632e8798148b351ba2971a0a380a47352afc8d

URL: https://github.com/llvm/llvm-project/commit/66632e8798148b351ba2971a0a380a47352afc8d
DIFF: https://github.com/llvm/llvm-project/commit/66632e8798148b351ba2971a0a380a47352afc8d.diff

LOG: [libunwind] [SEH] Handle ExceptionContinueExecution in forced unwinding

This fixes the libcxxabi test force_unwind3.pass.cpp when run on native
Windows.

When unwinding past the main thread function into the system functions
that brought up the thread, we can hit functions whose personality
functions return ExceptionContinueExecution (instead of the regular
ExceptionContinueSearch). Interpret this as a signal to stop the
unwind.

Curiously, in this case, it does return ExceptionContinueSearch if
running within a debugger.

Differential Revision: https://reviews.llvm.org/D147739

Added: 
    

Modified: 
    libunwind/src/Unwind-seh.cpp

Removed: 
    


################################################################################
diff  --git a/libunwind/src/Unwind-seh.cpp b/libunwind/src/Unwind-seh.cpp
index 5c87975cffb3..150ba6453a22 100644
--- a/libunwind/src/Unwind-seh.cpp
+++ b/libunwind/src/Unwind-seh.cpp
@@ -217,6 +217,7 @@ __libunwind_seh_personality(int version, _Unwind_Action state,
                                                            disp_ctx->ContextRecord,
                                                            disp_ctx);
   switch (ms_act) {
+  case ExceptionContinueExecution: return _URC_END_OF_STACK;
   case ExceptionContinueSearch: return _URC_CONTINUE_UNWIND;
   case 4 /*ExceptionExecuteHandler*/:
     return phase2 ? _URC_INSTALL_CONTEXT : _URC_HANDLER_FOUND;
@@ -304,6 +305,12 @@ unwind_phase2_forced(unw_context_t *uc,
         // We may get control back if landing pad calls _Unwind_Resume().
         __unw_resume(&cursor2);
         break;
+      case _URC_END_OF_STACK:
+        _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
+                                   "personality returned "
+                                   "_URC_END_OF_STACK",
+                                   (void *)exception_object);
+        break;
       default:
         // Personality routine returned an unknown result code.
         _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
@@ -312,6 +319,8 @@ unwind_phase2_forced(unw_context_t *uc,
                                    (void *)exception_object, personalityResult);
         return _URC_FATAL_PHASE2_ERROR;
       }
+      if (personalityResult == _URC_END_OF_STACK)
+        break;
     }
   }
 


        


More information about the cfe-commits mailing list