Skip to content

Commit

Permalink
Add limit to stacktrace length when parsing in issue_filing. (#4253)
Browse files Browse the repository at this point in the history
We recently encountered an 80MB stacktrace blocking our issue filing.

Setting a somewhat arbitrary 300000 length limit here. Looking at our
stack_analyzer_data testcases, this should be plenty (wycheproof is an
outlier):

```
43468 ./asan_uaf.txt
47231 ./cdb_stack_overflow.txt
47648 ./asan_stack_overflow2.txt
49057 ./tsan_use_after_free.txt
53914 ./asan_stack_overflow.txt
67879 ./java_fatal_exception.txt
158842 ./android_kernel_no_parens.txt
158977 ./android_kernel.txt
270382 ./cdb_other.txt
488612 ./wycheproof.txt
```
  • Loading branch information
oliverchang authored Sep 18, 2024
1 parent d1e5b9e commit 7684841
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions src/clusterfuzz/_internal/issue_management/issue_filer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.system import environment

_MAX_STACKTRACE_LEN_FOR_PARSING = 300000

NON_CRASH_TYPES = [
'Data race',
'Direct-leak',
Expand Down Expand Up @@ -262,6 +264,10 @@ def get_label_pattern(label):

def get_memory_tool_labels(stacktrace):
"""Distinguish memory tools used and return corresponding labels."""
if len(stacktrace) > _MAX_STACKTRACE_LEN_FOR_PARSING:
# Some stacktraces to too huge to do this on.
return [t['label'] for t in MEMORY_TOOLS_LABELS if t['token'] in stacktrace]

# Remove stack frames and paths to source code files. This helps to avoid
# confusion when function names or source paths contain a memory tool token.
data = ''
Expand Down Expand Up @@ -338,23 +344,18 @@ def file_issue(testcase,
testcase.crash_type)
properties = policy.get_new_issue_properties(
is_security=testcase.security_flag, is_crash=is_crash)
logs.info('got properties')

issue = issue_tracker.new_issue()
issue.title = data_handler.get_issue_summary(testcase)
issue.body = data_handler.get_issue_description(
testcase, reporter=user_email, show_reporter=True)

logs.info('Set issue body')

# Add reproducibility flag label.
if testcase.one_time_crasher_flag:
issue.labels.add(policy.label('unreproducible'))
else:
issue.labels.add(policy.label('reproducible'))

logs.info('Set repro')

# Chromium-specific labels.
if issue_tracker.project in ('chromium', 'chromium-testing'):
if testcase.security_flag:
Expand All @@ -379,15 +380,11 @@ def file_issue(testcase,
for label in additional_labels:
issue.labels.add(policy.substitution_mapping(label))

logs.info('Set automatic labels')

# Add crash-type-specific label
crash_type_label = policy.label_for_crash_type(testcase.crash_type)
if crash_type_label:
issue.labels.add(policy.substitution_mapping(crash_type_label))

logs.info('Set crash_type label')

# Add labels from crash metadata.
for crash_category in testcase.get_metadata('crash_categories', []):
crash_category_label = policy.label_for_crash_category(crash_category)
Expand All @@ -400,8 +397,6 @@ def file_issue(testcase,
for component in automatic_components:
issue.components.add(component)

logs.info('Set automatic components')

# Add issue assignee from the job definition and fuzzer.
automatic_assignee = data_handler.get_additional_values_for_variable(
'AUTOMATIC_ASSIGNEE', testcase.job_type, testcase.fuzzer_name)
Expand All @@ -411,8 +406,6 @@ def file_issue(testcase,
else:
issue.status = properties.status

logs.info('Set automatic assignee')

fuzzer_metadata = testcase.get_metadata('issue_metadata')
if fuzzer_metadata and 'assignee' in fuzzer_metadata:
issue.status = policy.status('assigned')
Expand All @@ -422,7 +415,6 @@ def file_issue(testcase,
# Add additional ccs from the job definition and fuzzer.
ccs = data_handler.get_additional_values_for_variable(
'AUTOMATIC_CCS', testcase.job_type, testcase.fuzzer_name)
logs.info('Set automatic_ccs')

# For externally contributed fuzzers, potentially cc the author.
# Use fully qualified fuzzer name if one is available.
Expand Down Expand Up @@ -450,7 +442,6 @@ def file_issue(testcase,
should_restrict_issue = (
issue_restrictions == 'all' or
(issue_restrictions == 'security' and testcase.security_flag))
logs.info('Set restrictions')

has_accountable_people = (
bool(ccs) and not data_handler.get_value_from_job_definition(
Expand Down Expand Up @@ -481,8 +472,6 @@ def file_issue(testcase,
policy.deadline_policy_message):
issue.body += '\n\n' + policy.deadline_policy_message

logs.info('Set label subs.')

for cc in ccs:
issue.ccs.add(cc)

Expand All @@ -498,8 +487,6 @@ def file_issue(testcase,
for component in metadata_components:
issue.components.add(component)

logs.info('Added metadata components.')

if testcase.one_time_crasher_flag and policy.unreproducible_component:
issue.components.add(policy.unreproducible_component)

Expand Down

0 comments on commit 7684841

Please sign in to comment.