fixed #9965: improved stack trace overview in daca crash report (#3122)

- HTML escape the traces
- handle traces without a code line
- handle frames without a source file
- handle frames without an address
This commit is contained in:
Oliver Stöneberg 2021-02-09 22:17:14 +01:00 committed by GitHub
parent 0fa225ecb5
commit ff125f6ac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 37 additions and 18 deletions

View File

@ -19,11 +19,12 @@ import urllib.error
import logging import logging
import logging.handlers import logging.handlers
import operator import operator
import html as html_lib
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
# changes) # changes)
SERVER_VERSION = "1.3.12" SERVER_VERSION = "1.3.13"
OLD_VERSION = '2.3' OLD_VERSION = '2.3'
@ -190,22 +191,40 @@ def crashReport(results_path: str) -> str:
location_index = crash_line.rfind(' at ') location_index = crash_line.rfind(' at ')
if location_index > 0: if location_index > 0:
code_line = next(file_, '').strip() code_line = next(file_, '').strip()
stack_trace = [] else:
while True: code_line = ''
l = next(file_, '') stack_trace = []
m = re.search(r'(?P<number>#\d+) .* (?P<function>.+)\(.*\) at (?P<location>.*)$', l) while True:
if not m: l = next(file_, '')
break if not l.strip():
break
# #0 0x00007ffff71cbf67 in raise () from /lib64/libc.so.6
m = re.search(r'(?P<number>#\d+) .* (?P<function>.+)\(.*\) from (?P<binary>.*)$', l)
if m:
stack_trace.append(m.group('number') + ' ' + m.group('function') + '(...) from ' + m.group('binary'))
continue
# #11 0x00000000006f2414 in valueFlowNumber (tokenlist=tokenlist@entry=0x7fffffffc610) at build/valueflow.cpp:2503
m = re.search(r'(?P<number>#\d+) .* (?P<function>.+)\(.*\) at (?P<location>.*)$', l)
if m:
stack_trace.append(m.group('number') + ' ' + m.group('function') + '(...) at ' + m.group('location')) stack_trace.append(m.group('number') + ' ' + m.group('function') + '(...) at ' + m.group('location'))
key = hash(' '.join(stack_trace)) continue
# #18 ForwardTraversal::updateRecursive (this=0x7fffffffb3c0, tok=0x14668a0) at build/forwardanalyzer.cpp:415
m = re.search(r'(?P<number>#\d+) (?P<function>.+)\(.*\) at (?P<location>.*)$', l)
if m:
stack_trace.append(m.group('number') + ' ' + m.group('function') + '(...) at ' + m.group('location'))
continue
if key in stack_traces: print('{} - unmatched stack frame - {}'.format(package, l))
stack_traces[key]['code_line'] = code_line break
stack_traces[key]['stack_trace'] = stack_trace key = hash(' '.join(stack_trace))
stack_traces[key]['n'] += 1
stack_traces[key]['packages'].append(package) if key in stack_traces:
else: stack_traces[key]['code_line'] = code_line
stack_traces[key] = {'stack_trace': stack_trace, 'n': 1, 'code_line': code_line, 'packages': [package], 'crash_line': crash_line} stack_traces[key]['stack_trace'] = stack_trace
stack_traces[key]['n'] += 1
stack_traces[key]['packages'].append(package)
else:
stack_traces[key] = {'stack_trace': stack_trace, 'n': 1, 'code_line': code_line, 'packages': [package], 'crash_line': crash_line}
break break
html += '</pre>\n' html += '</pre>\n'
@ -213,9 +232,9 @@ def crashReport(results_path: str) -> str:
html += '<b>Stack traces</b>\n' html += '<b>Stack traces</b>\n'
for stack_trace in sorted(list(stack_traces.values()), key=lambda x: x['n'], reverse=True): for stack_trace in sorted(list(stack_traces.values()), key=lambda x: x['n'], reverse=True):
html += 'Packages: ' + ' '.join(['<a href="' + p + '">' + p + '</a>' for p in stack_trace['packages']]) + '\n' html += 'Packages: ' + ' '.join(['<a href="' + p + '">' + p + '</a>' for p in stack_trace['packages']]) + '\n'
html += stack_trace['crash_line'] + '\n' html += html_lib.escape(stack_trace['crash_line']) + '\n'
html += stack_trace['code_line'] + '\n' html += html_lib.escape(stack_trace['code_line']) + '\n'
html += '\n'.join(stack_trace['stack_trace']) + '\n\n' html += html_lib.escape('\n'.join(stack_trace['stack_trace'])) + '\n\n'
html += '</pre>\n' html += '</pre>\n'
html += '</body></html>\n' html += '</body></html>\n'