Commit e07ab6c
Luca Toniolo
Fix uninitialized read in bezier9MaxCurvature when called via bezier9InitFast
bezier9MaxCurvature iterated the dκ/ds and 9D dκ/ds loops up to
BEZIER9_ARC_LENGTH_SAMPLES (1024) regardless of how many samples were
actually populated. bezier9InitFast fills only SAMPLES_FAST (32) entries
of t_table[]/s_table[], leaving slots [33..1024] holding uninitialized
stack memory from the caller.
Reading those slots produced garbage max_dkappa_ds values that depended
on prior call-stack contents. Since max_dkappa_ds feeds the centripetal
jerk cap v_jerk = cbrt(j_max * dt / max_dkappa_ds) inside the blend
optimizer, the resulting blend v_plan was history-dependent: the same
gcode produced different execution times depending on what tolerance the
previous program used (different prior runs left different stack patterns,
creating multiple stable timing fixed points).
Fix: clamp the loop bound to b->arc_samples for both the 3D and 9D
curvature-rate scans, with a safety fallback to the full size if the
field is out of range.
Introduced by 43516ac "Fast bezier init for blend optimizer".1 parent 806a593 commit e07ab6c
1 file changed
+11
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
768 | 768 | | |
769 | 769 | | |
770 | 770 | | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
771 | 779 | | |
772 | 780 | | |
773 | | - | |
| 781 | + | |
774 | 782 | | |
775 | 783 | | |
776 | 784 | | |
| |||
788 | 796 | | |
789 | 797 | | |
790 | 798 | | |
| 799 | + | |
791 | 800 | | |
792 | 801 | | |
793 | | - | |
| 802 | + | |
794 | 803 | | |
795 | 804 | | |
796 | 805 | | |
| |||
0 commit comments