Feature #11955
Preprocessor: enforce OpenEdge's 255-level include nesting limit
50%
Related issues
History
#1 Updated by Paula Păstrăguș 6 days ago
- Related to Feature #11741: implement a fully featured Language Server Protocol (LSP) server for 4GL code added
#2 Updated by Paula Păstrăguș 6 days ago
A 4GL include may pull itself in, directly or through other includes. OpenEdge allows this, and stops it only at its nesting limit. FWD's preprocessor has no limit: an include which references itself with no condition, or under one which never turns false, is expanded without end.
OpenEdge behaviour (checked in 11.6): Files may nest 255 levels deep, the program counted, so an include nests 254 deep at most.
#3 Updated by Paula Păstrăguș 6 days ago
Testcase:
depth.i:
&IF LENGTH("{1}") = {2} &THEN
MESSAGE "depth.i reached level {2}".
&ELSE
{pmp-test/depth.i {1}x {2}}
&ENDIF
depth-main.p:
{pmp-test/depth.i x 255}
When a value >= 255 is passed to depth.i, OE shows an error, and it doesn't preprocess the main program, explicitly saying that the File has compilation errors.
#4 Updated by Paula Păstrăguș 5 days ago
- Status changed from New to WIP
- Assignee set to Paula Păstrăguș
- % Done changed from 0 to 50
- reviewer Greg Shah added
Committed the solution as rev 16795 / branch 11955a.
Next, I'll create some testcases to fully validate the solution, but so far, the one mentioned in my prev rev is working now, and if 10000 is passed for example, this will be shown in the conversion log:
[java] Error in ./abl/pmp-test/depth.i#4:282 ==> Nested recursion limit of 255 exceeded in preprocessor expansion.
[java]
[java] com.goldencode.p2j.preproc.PreprocessorException: Nested recursion limit of 255 exceeded in preprocessor expansion.
Please note that the stack trace was reduced, otherwise the conversion output would have been filled with a lot of unnecessary calls.
#7 Updated by Greg Shah 5 days ago
Please commit your testcases and update Preprocessor Testcases. You'll have to compare versus trunk (the results in the wiki page may relate to 11747a right now).