Skip to content

Commit c0c4798

Browse files
authored
Merge pull request #129 from devdanzin/oom-dedup-msg-type-conflation
oom_dedup: don't conflate type-specific fatal-msg keys
2 parents 76f1e77 + 2b86920 commit c0c4798

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

fusil/python/oom_dedup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,16 @@ def match(c, snap):
124124
if hit:
125125
return hit, "assert"
126126
if c.get("fatal_msg"):
127+
# Match when the cataloged key is a prefix of the crash message (a key may be a short
128+
# signature, e.g. "_Py_CheckFunctionResult:") OR the (truncation-shortened) crash
129+
# message is a prefix of the key. The second clause must use the FULL crash message,
130+
# not a fixed [:30] slice -- a short slice stops before the discriminating content
131+
# (e.g. "_Py_Dealloc: Deallocator of type '<TYPE>'") and conflates type-specific keys
132+
# (OOM-0007 'Context' vs OOM-0023 '_StoreAction'), mislabelling any new type.
127133
hit = set(
128134
o
129135
for k, o in snap["msg"]
130-
if c["fatal_msg"].startswith(k) or k.startswith(c["fatal_msg"][:30])
136+
if c["fatal_msg"].startswith(k) or k.startswith(c["fatal_msg"])
131137
)
132138
if hit:
133139
return hit, "msg"

tests/python/test_oom_dedup.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,30 @@ def test_match_by_msg(self):
8989
ids, _ = self._match(FATAL_0022)
9090
self.assertEqual(ids, {"OOM-0022"})
9191

92+
def test_msg_match_distinguishes_by_type(self):
93+
# Two type-specific "Deallocator of type 'X'" msg keys must not be conflated by their
94+
# shared prefix: each known type maps to its own bug, and a NEW type matches neither
95+
# (a too-short prefix slice used to ignore the type and collide the whole family).
96+
snap = oom_dedup.load_snapshot(
97+
[
98+
"OOM-0007\tfatal\tmsg\t"
99+
"_Py_Dealloc: Deallocator of type 'Context' cleared the curre",
100+
"OOM-0023\tfatal\tmsg\t"
101+
"_Py_Dealloc: Deallocator of type '_StoreAction' cleared the ",
102+
]
103+
)
104+
105+
def decide_type(t):
106+
text = (
107+
"Fatal Python error: _Py_Dealloc: Deallocator of type '%s' "
108+
"cleared the current exception" % t
109+
)
110+
return oom_dedup.match(oom_dedup.classify(text), snap)[0]
111+
112+
self.assertEqual(decide_type("Context"), {"OOM-0007"})
113+
self.assertEqual(decide_type("_StoreAction"), {"OOM-0023"})
114+
self.assertEqual(decide_type("collections.deque"), set()) # new type -> no match
115+
92116
def test_near_line(self):
93117
ids, how = self._match(ABORT_NEAR)
94118
self.assertEqual(ids, {"OOM-0004"})

0 commit comments

Comments
 (0)