step-examples/12-13-writer-pathology/Wr013.stp
Sources
- OCCT bug "kernel chokes on forward refs"
- bug-reporter language: "ref to undefined #N", "forward declaration"
Sender
Writers that emit entities in topological-construction order without a topological sort; observed in some open-source exporters
Description
The producer emits `#5 = ORIENTED_EDGE(..,#10,..)` before `#10` has been defined. Spec-conforming readers must do a two-pass parse (or a deferred-resolution mechanism), but a class of single-pass kernels reports "reference to undefined instance #10" and rejects. Bug-reporter language: "forward references in STEP", "ref before def", "kernel doesn't support out-of-order STEP".
Reproducer recipe
`#5 = CARTESIAN_POINT('p',(0.,0.,0.));` followed later by `#1 = AXIS2_PLACEMENT_3D('a',#5,$,$);` — but `#5` appears first; or, more pathologically, `#1 = .. (#5,..);` first, then `#5 = ..;` second (forward).
Expected kernel behavior
implement two-pass parsing or deferred-resolution; the spec permits forward references. Reject only if a reference remains unresolved after the full file is parsed.
Notes
Lh006-class issue but writer-attributable.
Expected validation
occt=empty/empty gmsh=empty ifc=schema_n/a
Byte assertions
matches(rb'(?s)#1=AXIS2_PLACEMENT_3D[^;]+#5[^;]+;.*#5=CARTESIAN_POINT')matches(rb'(?s)#1=[^;]+#5')
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/* Wr013: forward reference â #1 references #5 before #5 is defined */ 3HEADER; 4FILE_DESCRIPTION(('Wr013 - forward reference to undefined instance'),'2;1'); 5FILE_NAME('Wr013.stp','2026-06-20T00:00:00',('auto-generated'),(''), 6 'auto-generated','',''); 7FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 3 1 1 }')); 8ENDSEC; 9DATA; 10/* Defect: #1 references #5 which has not yet been defined at this point */ 11/* A single-pass parser would see an unresolved reference at #1 parse time */ 12#1=AXIS2_PLACEMENT_3D('placement',#5,#6,#7); 13#2=PLANE('face-plane',#1); 14#3=CARTESIAN_POINT('p1',(1.,0.,0.)); 15#4=CARTESIAN_POINT('p2',(1.,1.,0.)); 16/* #5, #6, #7 are defined after #1 â forward references */ 17#5=CARTESIAN_POINT('origin',(0.,0.,0.)); 18#6=DIRECTION('zdir',(0.,0.,1.)); 19#7=DIRECTION('xdir',(1.,0.,0.)); 20#8=GEOMETRIC_CURVE_SET('forward-ref',(#3,#4)); 21ENDSEC; 22END-ISO-10303-21;