Skip to content

[BUG] G29 W with X and Y uses an uninitialised variable with AUTO_BED_LEVELING_BILINEAR #23791

@tombrazier

Description

@tombrazier

Did you test the latest bugfix-2.0.x code?

Yes, and the problem still exists.

Bug Description

In GcodeSuite::G29() in Marlin/src/gcode/bedlevel/abl/G29.cpp at line 300 is the following code:

          i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x;
          j = (ry - bilinear_start.y + 0.5 * abl.gridSpacing.y) / abl.gridSpacing.y;

When this code executes, abl.gridSpacing is uninitialised. bilinear_grid_spacing should be used instead.

Bug Timeline

It has been in the code since at least 2017.

Expected behavior

I expect the X and Y parameters to be converted into equivalent I and J parameters.

Actual behavior

The actual behaviour is undefined. The z value for some grid point will be set but not necessarily the one specified.

Steps to Reproduce

  1. G28
  2. G29
  3. G29 W X200 Y200 Z2
  4. M420 V

On my 200x200 bed with a 3x3 grid this should result in something like

Bilinear Leveling Grid:
      0      1      2
 0 +0.084 -0.016 +0.039
 1 +0.082 +0.195 -0.038
 2 +0.023 +0.224 +2.000

In reality the 0, 0 value gets set to 2.0 rather than the 2, 2 value.

Version of Marlin Firmware

Latest bugfix branch

Printer model

Custom ATMega256 based machine

Electronics

No response

Add-ons

No response

Bed Leveling

ABL Bilinear mesh

Your Slicer

No response

Host Software

No response

Additional information & file uploads

config.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions