alamb commented on code in PR #2400:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2400#discussion_r4423303312
##########
src/ast/spans.rs:
##########
@@ -3423,4 +3431,48 @@ SETTINGS update_parallel_mode = 'auto'"#;
assert_eq!(test.get_source(expr.span()), expected, "{sql}");
}
}
+
+ #[test]
+ #[cfg(feature = "recursive-protection")]
+ fn test_deeply_nested_expr_span_does_not_overflow() {
+ // 200k nested nodes on a 512 KiB stack overflow unless the walk grows
the stack.
+ std::thread::Builder::new()
+ .stack_size(512 * 1024)
+ .spawn(|| {
+ let mut expr = Expr::Identifier(crate::ast::Ident::new("x"));
+ for _ in 0..200_000 {
+ expr = Expr::Nested(Box::new(expr));
+ }
+ let _ = expr.span();
+ // Dropping the chain recurses too; leak it so the test
measures only the span walk.
Review Comment:
Or maybe I am missing something 🤔
What do you think @LucaCappelletti94 ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]