Skip to content

interp: an undefined named parameter in a sub definition reads as zero - #4725

Merged
grandixximo merged 1 commit into
LinuxCNC:masterfrom
grandixximo:named-param-defining-sub
Oct 26, 2026
Merged

grandixximo merged 1 commit into
LinuxCNC:masterfrom
grandixximo:named-param-defining-sub

Conversation

@grandixximo

Copy link
Copy Markdown
Contributor

While a sub is being defined, read_named_parameter() skips the "Named parameter not defined" error for an undefined named parameter, but it returned INTERP_OK without writing *double_ptr. The caller's local double stayed uninitialized, and read_real_value() then checked it with isnan()/isinf().

On i386 the leftover stack value is sometimes NaN, so a line like o#<sub> call inside a sub definition fails with Calculation resulted in 'not a number'. This is the intermittent tests/interp/oword-bug315-p2 failure on the i386 package job, for example on the Weblate PR #4723, which only touches .po files.

Valgrind shows the read on x86-64 as well:

Conditional jump or move depends on uninitialised value(s)
   at Interp::read_real_value (interp_read.cc:2860)
   by Interp::read_integer_value (interp_read.cc:791)
   by Interp::read_o (interp_read.cc:1620)
 Uninitialised value was created by a stack allocation
   at Interp::read_integer_value (interp_read.cc:788)

The fix sets the value to 0.0 in that branch. With it, valgrind is clean on oword-bug315-p2 and tests/interp passes (98/98).

read_named_parameter() skips the "not defined" error while a sub is being defined, but returned without writing the result. The caller's stack variable stayed uninitialized and read_real_value() then tested it for NaN and infinity. On i386 the leftover value is sometimes NaN, so "o#<sub> call" inside a sub definition failed with "Calculation resulted in 'not a number'"; tests/interp/oword-bug315-p2 flaked on the i386 CI job this way. Valgrind reports the uninitialized read on x86-64 too.
@grandixximo
grandixximo merged commit 16489af into LinuxCNC:master Oct 26, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant