Skip to content

Commit

Permalink
Add new test demonstrating endless loop with incorrect G71 parameters
Browse files Browse the repository at this point in the history
I found this issue in issue #1146. This example g-code program causes
the AXIS LinuxCNC GUI to get completely stuck while its memory use explode.
I decided to write a small test case to demonstrate the problem.
Discovered that the program cause the rs274 program to generate an
endless stream of repeated instructions, which I suspect is the cause of
the memory explosion.
  • Loading branch information
petterreinholdtsen committed Jul 26, 2022
1 parent feb8b23 commit 7b2517c
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/interp/g71-endless-loop/expected
@@ -0,0 +1,43 @@
N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... SET_XY_ROTATION(0.0000)
N..... SET_FEED_REFERENCE(CANON_XYZ)
N..... ON_RESET()
N..... COMMENT("G21 metric, G54 coordinate system 1, G18 ZX plane, G54 coordinate system")
N..... SELECT_PLANE(CANON_PLANE_XZ)
N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
N..... COMMENT("interpreter: continuing to use same coordinate system")
N..... COMMENT("G49 cancel tool length offset")
N..... USE_TOOL_LENGTH_OFFSET(0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000, 0.0000 0.0000 0.0000)
N..... COMMENT("G90 abs dist mode, G92.1 Reset coord sys offset")
N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... COMMENT("G94 Feed Mode=Units per Minute, G64p Best Possible Speed p=Motion Blend Tolerance")
N..... COMMENT("interpreter: feed mode set to units per minute")
N..... SET_FEED_MODE(0, 0)
N..... SET_FEED_RATE(0.0000)
N..... SET_MOTION_CONTROL_MODE(CANON_CONTINUOUS, 0.001000)
N..... SET_NAIVECAM_TOLERANCE(0.0010)
N..... COMMENT("Diameter Mode = 7, Radius Mode = 8")
N..... COMMENT("G91.1 = Relative Arc Offset Distance")
N..... SET_FEED_RATE(225.0000)
N..... STRAIGHT_TRAVERSE(15.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... STRAIGHT_TRAVERSE(15.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... STRAIGHT_FEED(15.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... STRAIGHT_FEED(10.0400, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... STRAIGHT_FEED(10.0400, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... STRAIGHT_FEED(10.0400, 0.0000, -14.0000, 0.0000, 0.0000, 0.0000)
N..... STRAIGHT_FEED(10.0400, 0.0000, -14.0000, 0.0000, 0.0000, 0.0000)
N..... ARC_FEED(-14.0400, 10.0000, -14.0000, 10.0000, 1, 0.0000, 0.0000, 0.0000, 0.0000)
N..... STRAIGHT_FEED(10.0000, 0.0000, -14.0400, 0.0000, 0.0000, 0.0000)
N..... STRAIGHT_FEED(3.0647, 0.0000, -14.0400, 0.0000, 0.0000, 0.0000)
N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... SET_XY_ROTATION(0.0000)
N..... SELECT_PLANE(CANON_PLANE_XY)
N..... SET_FEED_MODE(0, 0)
N..... SET_FEED_RATE(0.0000)
N..... STOP_SPINDLE_TURNING(0)
N..... SET_SPINDLE_MODE(0 0.0000)
N..... PROGRAM_END()
N..... ON_RESET()
N..... ON_RESET()
19 changes: 19 additions & 0 deletions tests/interp/g71-endless-loop/g71-endless-loop.ngc
@@ -0,0 +1,19 @@
G21 G18 G54 (G21 metric, G54 coordinate system 1, G18 ZX plane, G54 coordinate system)
G49 (G49 cancel tool length offset)
G90 G92.1 (G90 abs dist mode, G92.1 Reset coord sys offset)
G94 G64 p0.001 (G94 Feed Mode=Units per Minute, G64p Best Possible Speed p=Motion Blend Tolerance)
G8 (Diameter Mode = 7, Radius Mode = 8)
G91.1 (G91.1 = Relative Arc Offset Distance)

O200 SUB
;Change the next line from G01 X10 Z0 to G01 X5 Z0 and Axis works fine but this isn't the part profile I need.
G01 X10 Z0
G01 X10 Z-14
G01 X3
G01 X7 Z-22
O200 ENDSUB

F225
;G71.1 Q200 X15.0 Z0 D0.04 I0.5 R1
G71.2 Q200 X15.0 Z0 D0.04 I0.5 R1
M2
24 changes: 24 additions & 0 deletions tests/interp/g71-endless-loop/test.sh
@@ -0,0 +1,24 @@
#!/bin/bash
#
# Demonstrate endless loop when encountering incorrect parameters in
# G71 call. Note, the expected output is not verified. No idea what
# it should look like on a successful termination of this endless
# loop.

rs274 -g g71-endless-loop.ngc | awk '{$1=""; print}' > result &
pid=$!

# Give it 10 seconds to complete
count=10
while [ 0 -lt $count ] && kill -0 $pid > /dev/null 2>&1 ; do
sleep 1
count=$(($count - 1))
done

if kill -0 $pid > /dev/null 2>&1; then
kill -9 $pid
echo "error: g71-endless-loop.ngc program seem to be stuck, killing"
exit 1
fi

exit 0

0 comments on commit 7b2517c

Please sign in to comment.