Traumflug / Teacup_Firmware

Firmware for RepRap and other 3D printers
http://forums.reprap.org/read.php?147
GNU General Public License v2.0
312 stars 199 forks source link

Host based simulator doesn't like my new code #66

Closed Traumflug closed 10 years ago

Traumflug commented 10 years ago

Look like the simulator doesn'T like the code I just committed onto the cross branch:

$ gdb --args ./sim testcases/straight-speeds.gcode --tracefile=straight.trace --time-scale=0 --gcode 
[...]
(gdb) run
Starting program: /home/mah/RepRap/Teacup_Firmware/./sim testcases/straight-speeds.gcode --tracefile=straight.trace --time-scale=0 --gcode
timer_init: warp-speed
opening testcases/straight-speeds.gcode
analog_init: not implemented in simulator
start
ok
[...] 
G90
ok 
ok 
G1 X5 F400
ok 

Program received signal SIGSEGV, Segmentation fault.
[...]
(gdb) bt
#0  0x000000000040146d in dda_create (dda=0x608388 <movebuffer+104>, target=target@entry=0x6089b8 <next_target+8>) at dda.c:94
#1  0x00000000004024d9 in enqueue_home (t=0x6089b8 <next_target+8>, endstop_check=<optimized out>, 
    endstop_stop_cond=<optimized out>) at dda_queue.c:124
#2  0x000000000040310c in enqueue (t=<optimized out>) at dda_queue.h:36
#3  process_gcode_command () at gcode_process.c:626
#4  0x0000000000402a78 in gcode_parse_char (c=240 '\360') at gcode_parse.c:351
#5  0x0000000000400fa2 in main (argc=<optimized out>, argv=<optimized out>) at mendel.c:258
(gdb) list
89    #ifdef LOOKAHEAD
90    // Number the moves to identify them; allowed to overflow.
91    static uint8_t idcnt = 0;
92    static DDA* prev_dda = NULL;
93  
94    if (prev_dda->done || dda->waitfor_temp)
95      prev_dda = NULL;
96    #endif
97  
98    if (dda->waitfor_temp)
(gdb) 
phord commented 10 years ago

It bisects to here:

commit 315a081ee89a15388bf82695fa05faf3690bc017
Author: Markus Hitter <mah@jump-ing.de>
Date:   Wed Nov 27 18:50:37 2013 +0100

gcode_parse.c: assume G1 only for stuff which might actually move.

Previously, even comments were run through dda_create(), quite a waste
of time.
phord commented 10 years ago

Reverting that commit doesn't fix it. Investigating...

phord commented 10 years ago

Fixed. The code in 03631ce10c2875c99b1d5489cfdb4bc2d6abad7b dereferenced NULL, but AVR didn't notice:

static DDA* prev_dda = NULL;
if (prev_dda->done)
  prev_dda = NULL;