File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -1132,6 +1132,22 @@ def test_filter_dealloc(self):
11321132 del i
11331133 gc .collect ()
11341134
1135+ @support .skip_wasi_stack_overflow ()
1136+ @support .skip_emscripten_stack_overflow ()
1137+ @support .requires_resource ('cpu' )
1138+ def test_filter_deep_nesting_recursion_error (self ):
1139+ # gh-137894: Test that deeply nested filter() iterator chains
1140+ # raise RecursionError instead of causing segmentation fault.
1141+ # This verifies that the tp_clear method prevents stack overflow
1142+ # during garbage collection of cyclic references.
1143+ i = filter (bool , range (1000000 ))
1144+ for _ in range (100000 ):
1145+ i = filter (bool , i )
1146+
1147+ # Should raise RecursionError, not segmentation fault
1148+ with self .assertRaises (RecursionError ):
1149+ list (i )
1150+
11351151 def test_getattr (self ):
11361152 self .assertTrue (getattr (sys , 'stdout' ) is sys .stdout )
11371153 self .assertRaises (TypeError , getattr )
You can’t perform that action at this time.
0 commit comments