Skip to content

Commit a879672

Browse files
committed
Fix python3.12 on ubuntu x86-64
1 parent 7152631 commit a879672

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

interpreter/python/python.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,17 @@ func Loader(ebpf interpreter.EbpfHandler, info *interpreter.LoaderInfo) (interpr
734734

735735
// Calls first: PyThread_tss_get(autoTSSKey)
736736
autoTLSKey = decodeStub(ef, pyruntimeAddr, "PyGILState_GetThisThreadState", 0)
737+
if autoTLSKey == libpf.SymbolValueInvalid {
738+
// Starting with Python 3.12, PyGILState_GetThisThreadState calls PyThread_tss_is_created
739+
// first before calling PyThread_tss_get.
740+
// On default builds of python (without `--enable-optimizations`, `--with-lto`), the calls
741+
// to PyThread_tss_is_created and PyThread_tss_get are not inlined, so the value of
742+
// autoTLSKey is stored in a register before being passed to both function calls. This
743+
// causes the decode disassembler to not find the value in the call instruction.
744+
// To work around this, we look into PyGILState_Release which as of Python 3.13,
745+
// calls PyThread_tss_get directly.
746+
autoTLSKey = decodeStub(ef, pyruntimeAddr, "PyGILState_Release", 0)
747+
}
737748
if autoTLSKey == libpf.SymbolValueInvalid {
738749
return nil, errors.New("unable to resolve autoTLSKey")
739750
}

0 commit comments

Comments
 (0)