-
Notifications
You must be signed in to change notification settings - Fork 14
Improve Python unwinding resilience #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
42f6c5a
1cc2e27
956cb0d
65c6e52
4a2573d
06b923f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -454,10 +454,12 @@ func (p *pythonInstance) getCodeObject(addr libpf.Address, | |
| if addr == 0 { | ||
| return nil, errors.New("failed to read code object: null pointer") | ||
| } | ||
| if value, ok := p.addrToCodeObject.Get(addr); ok { | ||
| m := value | ||
| if m.ebpfChecksum == ebpfChecksum { | ||
| return m, nil | ||
| if ebpfChecksum != 0 { | ||
| if value, ok := p.addrToCodeObject.Get(addr); ok { | ||
| m := value | ||
| if m.ebpfChecksum == ebpfChecksum { | ||
| return m, nil | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+457
to
464
|
||
|
|
||
|
|
@@ -512,7 +514,7 @@ func (p *pythonInstance) getCodeObject(addr libpf.Address, | |
|
|
||
| ebpfChecksumCalculated := (argCount << 25) + (kwonlyArgCount << 18) + | ||
| (flags << 10) + firstLineNo | ||
| if ebpfChecksum != ebpfChecksumCalculated { | ||
| if ebpfChecksum != 0 && ebpfChecksum != ebpfChecksumCalculated { | ||
| return nil, fmt.Errorf("read code object was stale: %x != %x", | ||
| ebpfChecksum, ebpfChecksumCalculated) | ||
| } | ||
|
|
@@ -533,7 +535,7 @@ func (p *pythonInstance) getCodeObject(addr libpf.Address, | |
| sourceFileName: libpf.Intern(sourceFileName), | ||
| firstLineNo: firstLineNo, | ||
| lineTable: lineTable, | ||
| ebpfChecksum: ebpfChecksum, | ||
| ebpfChecksum: ebpfChecksumCalculated, | ||
| } | ||
| p.addrToCodeObject.Add(addr, pco) | ||
| return pco, nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -130,7 +130,12 @@ static EBPF_INLINE ErrorCode process_python_frame( | |||
| if (bpf_probe_read_user(pss->code, sizeof(pss->code), py_codeobject)) { | ||||
| DEBUG_PRINT("Failed to read PyCodeObject at 0x%lx", (unsigned long)(py_codeobject)); | ||||
| increment_metric(metricID_UnwindPythonErrBadCodeObjectArgCountAddr); | ||||
| return ERR_PYTHON_BAD_CODE_OBJECT_ADDR; | ||||
| // Push the frame with the code object address so the agent can try to | ||||
| // read it via /proc/pid/mem (which supports page faults unlike BPF). | ||||
| // codeobject_id=0 distinguishes this from a successful read. | ||||
|
Comment on lines
+133
to
+135
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does the reading via /proc/pid/mem happen?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||
| file_id = (u64)py_codeobject; | ||||
| lineno = py_encode_lineno(0, (u32)py_f_lasti); | ||||
| goto push_frame; | ||||
| } | ||||
|
|
||||
| int py_argcount = *(int *)(&pss->code[pyinfo->PyCodeObject_co_argcount]); | ||||
|
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When/why can this checksum be 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the bpf_read fails for the py code object.