[PATCH smatch-devel 2/5] smatch: prevent recursive --ai state dumps
Harshit Mogalapalli <[email protected]>
| Newsgroups | org.kernel.vger.smatch |
|---|---|
| Message-ID | <[email protected]> |
The --ai report wrapper prints the current stree after every diagnostic.
__print_stree() emits each state with sm_msg(), so those messages start
new AI reports and dump the same stree recursively until stack overflow.
Disable AI report wrapping while serializing a stree, then restore the
option after the dump. Normal diagnostics and each outer AI report keep
their existing output, while nested dump messages cannot recurse.
Fixes: 47487a9dbf4e ("smatch: add broken --ai option")
Assisted-by: Codex:5.6
Signed-off-by: Harshit Mogalapalli <[email protected]>
---
smatch.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/smatch.h b/smatch.h
index 0db2062e1f5d..681be3354bc1 100644
--- a/smatch.h
+++ b/smatch.h
@@ -447,7 +447,10 @@ do { \
sm_printf(msg); \
sm_printf("\n"); \
if (option_ai) { \
+ int __saved_option_ai = option_ai; \
+ option_ai = 0; \
__print_cur_stree(); \
+ option_ai = __saved_option_ai; \
sm_printf("end report: %d\n", __this_warn); \
} \
} while (0)
--
2.52.0