-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[compiler-rt] Fix frame numbering for unparsable frames. #148278
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
[compiler-rt] Fix frame numbering for unparsable frames. #148278
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Jesse Schwartzentruber (jschwartzentruber) ChangesThis can happen when JIT code is run, and we can't symbolize those frames, but they should remain numbered in the stack. An example spidermonkey trace:
Without this change, the following symbolization is output:
The last frame has a duplicate number. With this change the numbering is correct:
Full diff: https://github.com/llvm/llvm-project/pull/148278.diff 1 Files Affected:
diff --git a/compiler-rt/lib/asan/scripts/asan_symbolize.py b/compiler-rt/lib/asan/scripts/asan_symbolize.py
index 058a1614b55e6..e70f987f03fe6 100755
--- a/compiler-rt/lib/asan/scripts/asan_symbolize.py
+++ b/compiler-rt/lib/asan/scripts/asan_symbolize.py
@@ -22,7 +22,6 @@
import argparse
import bisect
import errno
-import getopt
import logging
import os
import re
@@ -38,6 +37,7 @@
allow_system_symbolizer = True
force_system_symbolizer = False
+
# FIXME: merge the code that calls fix_filename().
def fix_filename(file_name):
if fix_filename_patterns:
@@ -507,20 +507,29 @@ def symbolize_address(self, addr, binary, offset, arch):
assert result
return result
- def get_symbolized_lines(self, symbolized_lines, inc_frame_counter=True):
+ def get_symbolized_lines(self, symbolized_lines):
if not symbolized_lines:
- if inc_frame_counter:
- self.frame_no += 1
- return [self.current_line]
- else:
- assert inc_frame_counter
- result = []
- for symbolized_frame in symbolized_lines:
- result.append(
- " #%s %s" % (str(self.frame_no), symbolized_frame.rstrip())
+ # If it is an unparsable frame, but contains a frame counter and address
+ # replace the frame counter so the stack is still consistent.
+ unknown_stack_frame_format = r"^( *#([0-9]+) +)(0x[0-9a-f]+) +.*"
+ match = re.match(unknown_stack_frame_format, self.current_line)
+ if match:
+ rewritten_line = (
+ self.current_line[: match.start(2)]
+ + str(self.frame_no)
+ + self.current_line[match.end(2) :]
)
self.frame_no += 1
- return result
+ return [rewritten_line]
+ # Not a frame line so don't increment the frame counter.
+ return [self.current_line]
+ result = []
+ for symbolized_frame in symbolized_lines:
+ result.append(
+ " #%s %s" % (str(self.frame_no), symbolized_frame.rstrip())
+ )
+ self.frame_no += 1
+ return result
def process_logfile(self):
self.frame_no = 0
@@ -546,8 +555,7 @@ def process_line_posix(self, line):
match = re.match(stack_trace_line_format, line)
if not match:
logging.debug('Line "{}" does not match regex'.format(line))
- # Not a frame line so don't increment the frame counter.
- return self.get_symbolized_lines(None, inc_frame_counter=False)
+ return self.get_symbolized_lines(None)
logging.debug(line)
_, frameno_str, addr, binary, offset = match.groups()
@@ -603,6 +611,7 @@ def _load_plugin_from_file_impl_py_gt_2(self, file_path, globals_space):
def load_plugin_from_file(self, file_path):
logging.info('Loading plugins from "{}"'.format(file_path))
globals_space = dict(globals())
+
# Provide function to register plugins
def register_plugin(plugin):
logging.info("Registering plugin %s", plugin.get_name())
@@ -779,9 +788,13 @@ def __str__(self):
arch=self.arch,
start_addr=self.start_addr,
end_addr=self.end_addr,
- module_path=self.module_path
- if self.module_path == self.module_path_for_symbolization
- else "{} ({})".format(self.module_path_for_symbolization, self.module_path),
+ module_path=(
+ self.module_path
+ if self.module_path == self.module_path_for_symbolization
+ else "{} ({})".format(
+ self.module_path_for_symbolization, self.module_path
+ )
+ ),
uuid=self.uuid,
)
|
This can happen when JIT code is run, and we can't symbolize those frames, but they should remain numbered in the stack. see: llvm/llvm-project#148278
This can happen when JIT code is run, and we can't symbolize those frames, but they should remain numbered in the stack. see: llvm/llvm-project#148278
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.
Just an OSS contributor, I don't have commit access, but wanted to leave some suggestions in case they help. Hope they're helpful!
@davidmrdavid FYI since you've merged three pull requests (#125924, #122990, #117929) you're eligible for commit access if you wish: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access |
Thanks @thurstond, that would be wonderful! I'll look to follow those instructions later :) Thanks! Update: @thurstond - I created an issue here, thanks! #151001 |
c3e8617
to
7aa8d35
Compare
@jschwartzentruber - is there a simple test (either manual or automated) that we can run/add to the PR to validate these changes? |
I've commented my approval there, and also pinged some reviewers to request the second approval :-) |
I looked for existing automated tests but didn't see any. Happy to add a test if there is a framework for it. The manual steps I used to reproduce the issue use spidermonkey crashing in JIT code as an example:
|
Maybe something similar to |
I was able to test your patch manually using the following testcase:
|
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.
Ideally, please add a test case (bonus points if the test case is precommitted in a separate PR, and this PR rebased on top of that), but I'd be happy for this to be merged as-is.
Thanks for the patch!
9f5a493
to
d5d753e
Compare
Add test for #148278. This was written with the aide of ChatGPT 5 and tested on Linux x86_64.
This can happen when JIT code is run, and we can't symbolize those frames, but they should remain numbered in the stack.
d5d753e
to
0b3e75a
Compare
@jschwartzentruber Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/21874 Here is the relevant piece of the build log for the reference
|
…rsable frames. #148278" (#154397) Reason: buildbot failure (https://lab.llvm.org/buildbot/#/builders/51/builds/21874/steps/9/logs/stdio) Fix by restricting test to x86-64
…rsable frames. llvm#148278" Reason: buildbot failure (https://lab.llvm.org/buildbot/#/builders/51/builds/21874/steps/9/logs/stdio) Fix by restricting test to x86-64
This can happen when JIT code is run, and we can't symbolize those frames, but they should remain numbered in the stack. An example spidermonkey trace:
Without this change, the following symbolization is output:
The last frame has a duplicate number. With this change the numbering is correct: