step-examples/12-11-adversarial/Ad128.stp
Sources
- https://github.com/prusa3d/PrusaSlicer/issues/11305 (PrusaSlicer 2.6.1 + OCCT 7.x: stack overflow on import of file with circular ORIENTED_EDGE reference). B4 wave-4 DEF-B (LGPL-clean — pattern only, no bytes copied).
Description
STEP file containing a self-referential ORIENTED_EDGE entity: `#N=ORIENTED_EDGE('',*,*,#N,.T.);` where the edge_element forward-reference equals the entity's own ID. In importers that chase edge_element references recursively without a cycle guard (ORIENTED_EDGE → EdgeStart() → EdgeEnd() → EdgeStart() → …), the resolver recurses until the call stack exhausts. OCCT detects the self-reference and skips the orphan entity; the valid planar face in the product chain loads normally as shape(1). The self-referential entity is a denial-of-service vector in embedded importers.
Reproducer recipe
Valid OPEN_SHELL planar face (1×1 square) with PRODUCT chain; followed by `#N=ORIENTED_EDGE('',*,*,#N,.T.)` where N is the entity's own ID (obtained via `f._next_id` before emit).
Expected kernel behavior
detect self-referential ORIENTED_EDGE and raise a parse error or skip cleanly; never recurse unboundedly on edge_element resolution. Pre-fix PrusaSlicer: stack overflow → crash.
Notes
Distinct from Ad004 (general complex-entity cycle) and Pf036 (MAPPED_ITEM cyclic assembly). This specific pattern targets the EdgeStart/EdgeEnd resolution path. Synonyms: "ORIENTED_EDGE self-reference stack overflow", "circular edge reference crash STEP", "PrusaSlicer stack overflow STEP import", "STEP cyclic ORIENTED_EDGE DoS", "edge element self-reference".
Expected validation
occt=shape(1)/shape(1) gmsh=shape(9) ifc=schema_n/a
Byte assertions
contains(b'ORIENTED_EDGE')contains(b"ORIENTED_EDGE('',*,*,")
Tier-3 assertions
load == "ok"
Cross-references
Live oracle output
No live oracle data — run _run_corpus to populate.
Fixture content
Show fixture bytes (with defect highlighting)
1ISO-10303-21; 2/* Ad128: ORIENTED_EDGE self-referential entity: #N=ORIENTED_EDGE('',*,*,#N,.T.) where the edge_element forward-ref equals the entity's own ID; mutual circular reference causes stack overflow on import (PrusaSlicer#11305); OPEN_SHELL planar face IS model entity â OCC yields shape(1) (cycle skipped) */ 3HEADER; 4FILE_DESCRIPTION(('Ad128'),'2;1'); 5FILE_NAME('Ad128.stp','2026-06-17T00:00:00',(''),(''),'cad-research-suite','',''); 6FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 3 1 1 }')); 7ENDSEC; 8DATA; 9#9000=APPLICATION_CONTEXT('mechanical design'); 10#1=CARTESIAN_POINT('',(0.0,0.0,0.0)); 11#2=DIRECTION('',(0.0,0.0,1.0)); 12#3=DIRECTION('',(1.0,0.0,0.0)); 13#4=AXIS2_PLACEMENT_3D('',#1,#2,#3); 14#5=PLANE('',#4); 15#6=CARTESIAN_POINT('',(0.0,0.0,0.0)); 16#7=CARTESIAN_POINT('',(1.0,0.0,0.0)); 17#8=CARTESIAN_POINT('',(1.0,1.0,0.0)); 18#9=CARTESIAN_POINT('',(0.0,1.0,0.0)); 19#10=VERTEX_POINT('',#6); 20#11=VERTEX_POINT('',#7); 21#12=VERTEX_POINT('',#8); 22#13=VERTEX_POINT('',#9); 23#14=DIRECTION('',(1.0,0.0,0.0)); 24#15=VECTOR('',#14,1.0); 25#16=LINE('',#6,#15); 26#17=EDGE_CURVE('',#10,#11,#16,.T.); 27#18=DIRECTION('',(0.0,1.0,0.0)); 28#19=VECTOR('',#18,1.0); 29#20=LINE('',#7,#19); 30#21=EDGE_CURVE('',#11,#12,#20,.T.); 31#22=DIRECTION('',(-1.0,0.0,0.0)); 32#23=VECTOR('',#22,1.0); 33#24=LINE('',#8,#23); 34#25=EDGE_CURVE('',#12,#13,#24,.T.); 35#26=DIRECTION('',(0.0,-1.0,0.0)); 36#27=VECTOR('',#26,1.0); 37#28=LINE('',#9,#27); 38#29=EDGE_CURVE('',#13,#10,#28,.T.); 39#30=ORIENTED_EDGE('',$,$,#17,.T.); 40#31=ORIENTED_EDGE('',$,$,#21,.T.); 41#32=ORIENTED_EDGE('',$,$,#25,.T.); 42#33=ORIENTED_EDGE('',$,$,#29,.T.); 43#34=EDGE_LOOP('',(#30,#31,#32,#33)); 44#35=FACE_OUTER_BOUND('',#34,.T.); 45#36=ADVANCED_FACE('',(#35),#5,.T.); 46#37=OPEN_SHELL('',(#36)); 47#38=SHELL_BASED_SURFACE_MODEL('',(#37)); 48#9050=PRODUCT_CONTEXT('',#9000,'mechanical'); 49#9051=PRODUCT('Ad128','Ad128','',(#9050)); 50#9052=PRODUCT_DEFINITION_FORMATION('','',#9051); 51#9053=PRODUCT_DEFINITION_CONTEXT('part definition',#9000,'design'); 52#9054=PRODUCT_DEFINITION('','','',#9052,#9053); 53#9055=PRODUCT_DEFINITION_SHAPE('','','',#9054); 54#9056=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.)); 55#9057=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.)); 56#9058=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT()); 57#9059=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.0E-7),#9056,'distance_accuracy_value',''); 58#9060=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#9059))GLOBAL_UNIT_ASSIGNED_CONTEXT((#9056,#9057,#9058))REPRESENTATION_CONTEXT('','3D')); 59#9061=MANIFOLD_SURFACE_SHAPE_REPRESENTATION('',(#38),#9060); 60#9062=SHAPE_DEFINITION_REPRESENTATION(#9055,#9061); 61#9063=ORIENTED_EDGE('',*,*,#9063,.T.); 62ENDSEC; 63END-ISO-10303-21;