Skip to content

Commit

Permalink
Merge 20250203
Browse files Browse the repository at this point in the history
Dest sha:   a1e14a5677329b9a90431a0da1fa7d53b66d491d
Source sha: bb0c9caf10fcb7341022f62383ff2eeb0b381766
dee7133a5  Bug 1943919 - Add TppRaiseInvalidParameter to the prefix list (#6875)  (Gabriele Svelto)
10a4ed945  build(deps): bump ruff from 0.8.6 to 0.9.1 (#6860)  (dependabot[bot])
8d6449d2b  Bug 1932405 - Improve signatures involving checked pointers (#6812)  (Gabriele Svelto)
c2e91175d  Bug 1929829 - Ignore g_malloc when generating signatures (#6798)  (Gabriele Svelto)
8bf7b5143  bug-1764633: remove non-printable/non-ascii characters from signature (#6782)  (Will Kahn-Greene)
  • Loading branch information
willkg committed Feb 3, 2025
1 parent bb85f09 commit 01f0114
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 6 deletions.
2 changes: 1 addition & 1 deletion siggen/cmd_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ def main(argv=None):
fp.write("\n")

for i, rule in enumerate(rules):
li = f"{i+1}. "
li = f"{i + 1}. "
fp.write("%s%s\n" % (li, indent(get_doc(rule), " " * len(li))))
fp.write("\n")
2 changes: 2 additions & 0 deletions siggen/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
SignatureIPCMessageName,
SignatureRunWatchDog,
SignatureShutdownTimeout,
SigPrintableCharsOnly,
SigTruncate,
StackOverflowSignature,
StackwalkerErrorSignatureRule,
Expand All @@ -37,6 +38,7 @@
StackOverflowSignature,
HungProcess,
# NOTE(willkg): These should always come last and in this order
SigPrintableCharsOnly,
SigFixWhitespace,
SigTruncate,
]
Expand Down
14 changes: 14 additions & 0 deletions siggen/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,20 @@ def action(self, crash_data, result):
return True


class SigPrintableCharsOnly(Rule):
"""Remove non-printable characters from signature."""

def action(self, crash_data, result):
original_sig = result.signature
sig = "".join(
[c for c in original_sig.strip() if c.isascii() and c.isprintable()]
)
if sig != original_sig:
result.set_signature(self.name, sig)
result.info(self.name, "unprintable characters removed")
return True


class SigFixWhitespace(Rule):
"""Fix whitespace in signatures.
Expand Down
5 changes: 5 additions & 0 deletions siggen/siglists/irrelevant_signature_re.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ __GI
gkrust_shared::oom_hook::hook
g_log
_g_log_abort
g_malloc
google_breakpad::CrashGenerationClient::RequestDumpForException
google_breakpad::ExceptionHandler::SignalHandler
google_breakpad::ExceptionHandler::WriteMinidumpWithException
Expand Down Expand Up @@ -135,6 +136,8 @@ mozcrt19\.dll
mozilla::AlignedBuffer<T>::Data
mozilla::ArrayIterator<T>
mozilla::Atomic<T>
mozilla::CheckCheckedUnsafePtrs<T>::Check
mozilla::CheckingPolicyAccess::NotifyCheckFailure
mozilla::detail::Atomic
mozilla::detail::BaseAutoLock
mozilla::detail::BaseMonitorAutoLock
Expand All @@ -144,6 +147,7 @@ mozilla::detail::IntrinsicMemoryOps
mozilla::detail::MemoryOperations
mozilla::detail::MutexImpl
mozilla::detail::RunnableMethodImpl<T>::RunnableMethodImpl
mozilla::detail::SupportCheckedUnsafePtrImpl<T>
mozilla::detail::ThreadLocalNativeStorage<T>::get
mozilla::detail::ThreadLocal<T>::get
mozilla::detail::VariantImplementation<T>::
Expand Down Expand Up @@ -180,6 +184,7 @@ mozilla::SegmentedVector<T>::SegmentImpl<T>::
mozilla::Span<T>
mozilla::StringBuffer::AddRef
mozilla::StringBuffer::Release
mozilla::SupportsCheckedUnsafePtr<T>::~SupportsCheckedUnsafePtr
mozilla::TaskController::GetRunnableForMTTask
mozilla::TaskQueue::
mozilla::ThreadEventQueue
Expand Down
3 changes: 2 additions & 1 deletion siggen/siglists/prefix_signature_re.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ memset
MessageLoop::PostTask_Helper
MessageLoop::PostTask
moz_malloc_size_of
mozilla::CheckCheckedUnsafePtrs<T>::Check
mozilla::CheckedInt
mozilla::CrashOnDanglingCheckedUnsafePtr::NotifyCheckFailure
mozilla::detail::InvalidArrayIndex_CRASH
mozilla::detail::nsTStringRepr<T>::
mozilla::Variant<T>::
Expand Down Expand Up @@ -238,6 +238,7 @@ strstr
syscall
SysFreeString
TlsGetValue
TppRaiseInvalidParameter
__ulock_wait
__unlink
unlink
Expand Down
2 changes: 1 addition & 1 deletion siggen/socorro_sha.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a1e14a5677329b9a90431a0da1fa7d53b66d491d
bb0c9caf10fcb7341022f62383ff2eeb0b381766
29 changes: 26 additions & 3 deletions siggen/tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,7 @@ def test_long_exception_description_with_line_number(self):
def test_no_description(self):
j = rules.JavaSignatureTool()
java_stack_trace = (
" SomeJavaException\n"
"at org.mozilla.lars.myInvention(larsFile.java:1234)"
" SomeJavaException\nat org.mozilla.lars.myInvention(larsFile.java:1234)"
)
sig, notes, debug_notes = j.generate(java_stack_trace, delimiter=": ")
e = "SomeJavaException: at org.mozilla.lars.myInvention(larsFile.java)"
Expand Down Expand Up @@ -1718,6 +1717,30 @@ def test_action_non_ascii_abort_message(self):
assert result.signature == "Abort | unknown | hello"


class TestSigPrintableCharsOnly:
@pytest.mark.parametrize(
"signature, expected",
[
("everything | fine", "everything | fine"),
# Non-printable null character
("libxul.so\x00 | frame2", "libxul.so | frame2"),
# Non-ascii emoji
("libxul.so\U0001f600 | frame2", "libxul.so | frame2"),
],
)
def test_whitespace_fixing(self, signature, expected):
rule = rules.SigPrintableCharsOnly()
result = generator.Result()
result.signature = signature
action_result = rule.action({}, result)
assert action_result is True
assert result.signature == expected
if signature != expected:
assert result.notes == [
"SigPrintableCharsOnly: unprintable characters removed"
]


class TestSigFixWhitespace:
@pytest.mark.parametrize(
"signature, expected",
Expand Down Expand Up @@ -1828,7 +1851,7 @@ def test_action(self):
assert sgr.action(crash_data, result) is True

# Verify the signature has been re-generated based on thread 0.
expected = "shutdownhang | MsgWaitForMultipleObjects | " "F_1152915508_____"
expected = "shutdownhang | MsgWaitForMultipleObjects | F_1152915508_____"
assert result.signature == expected
assert result.notes == []

Expand Down

0 comments on commit 01f0114

Please sign in to comment.