Skip to content

Commit 81fd875

Browse files
obdevwyfanxiaoLINxiansheng
authored andcommitted
fix: handle DW_EH_PE_signed and strip DW_EH_PE_indirect in PL exception handler for macOS ARM64 JIT compatibility
Co-authored-by: wyfanxiao <wyfanxiao@163.com> Co-authored-by: LINxiansheng <wangzelin19961202@gmail.com>
1 parent dd7a090 commit 81fd875

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/pl/ob_pl_exception_handling.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ uintptr_t ObPLEH::readEncodedPointer(const uint8_t **data, uint8_t encoding)
284284
// first get value
285285
switch (encoding & 0x0F) {
286286
case DW_EH_PE_absptr:
287+
case DW_EH_PE_signed:
287288
result = ReadType<uintptr_t>(p);
288289
break;
289290
case DW_EH_PE_uleb128:
@@ -353,6 +354,7 @@ unsigned ObPLEH::getEncodingSize(uint8_t Encoding)
353354

354355
switch (Encoding & 0x0F) {
355356
case DW_EH_PE_absptr:
357+
case DW_EH_PE_signed:
356358
return sizeof(uintptr_t);
357359
case DW_EH_PE_udata2:
358360
return sizeof(uint16_t);
@@ -537,6 +539,12 @@ _Unwind_Reason_Code ObPLEH::handleLsda(int version,
537539
uint8_t lpStartEncoding = *lsda++;
538540

539541
if (lpStartEncoding != DW_EH_PE_omit) {
542+
if (0 != (lpStartEncoding & DW_EH_PE_indirect)) {
543+
LOG_WARN_RET(OB_ERR_UNEXPECTED, "unexpected DW_EH_PE_indirect in lpStart encoding, "
544+
"LSDA likely unrelocated, skip frame",
545+
K(lpStartEncoding), K(pc), K(funcStart));
546+
return _URC_CONTINUE_UNWIND;
547+
}
540548
uint8_t relEnc = lpStartEncoding & 0x70;
541549
if (relEnc != DW_EH_PE_absptr && relEnc != DW_EH_PE_pcrel) {
542550
LOG_WARN_RET(OB_ERR_UNEXPECTED, "unsupported lpStart encoding in LSDA, skip frame",
@@ -557,6 +565,17 @@ _Unwind_Reason_Code ObPLEH::handleLsda(int version,
557565
uint8_t callSiteEncoding = *lsda++;
558566

559567
if (callSiteEncoding != DW_EH_PE_omit) {
568+
// Call site entries are function-relative offsets and should never use
569+
// DW_EH_PE_indirect. If the indirect flag is set, the LSDA pointer for
570+
// this frame is likely unrelocated (known issue with RuntimeDyld on
571+
// macOS ARM64 for certain JIT-compiled trigger packages). Skip this
572+
// frame and let the exception propagate to the caller.
573+
if (0 != (callSiteEncoding & DW_EH_PE_indirect)) {
574+
LOG_WARN_RET(OB_ERR_UNEXPECTED, "unexpected DW_EH_PE_indirect in call site encoding, "
575+
"LSDA likely unrelocated, skip frame",
576+
K(callSiteEncoding), K(pc), K(funcStart));
577+
return _URC_CONTINUE_UNWIND;
578+
}
560579
uint8_t relEnc = callSiteEncoding & 0x70;
561580
if (relEnc != DW_EH_PE_absptr && relEnc != DW_EH_PE_pcrel) {
562581
LOG_WARN_RET(OB_ERR_UNEXPECTED, "unsupported call site encoding in LSDA, skip frame",

0 commit comments

Comments
 (0)