Package: mawk
Version: 1.3.4.20240622-1
Severity: normal

Dear Maintainer,

Running mawk produces wrong output from rand() on i386:

  $ echo | mawk 'BEGIN {srand(10);} {print rand()};'
  0.158578
  $ echo | mawk 'BEGIN {srand(10);} {print rand()};'
  -0.276944
  $ echo | mawk 'BEGIN {srand(10);} {print rand()};'
  -0.387807
  $ echo | mawk 'BEGIN {srand(10);} {print rand()};'
  0.470306

The result of rand() should never be negative; and it should be
deterministic after calling srand().

This occurs on i386 (tested in sbuild --arch=i386 as part of debugging a
reproducible build problem of package openscad).

The expected output is the same value between 0 and 1, for example:

  $ echo | mawk 'BEGIN {srand(10);} {print rand()};'
  0.559536
  $ echo | mawk 'BEGIN {srand(10);} {print rand()};'
  0.559536
  $ echo | mawk 'BEGIN {srand(10);} {print rand()};'
  0.559536

The longer story, for completeness: I am the maintainer for openscad, and I
see openscad sometimes failing to build reproducibly on (only) i386 during
the past year. The root cause seems to be a test script that calls awk and
behaves unexpectedly due to getting a negative number out of rand().

The problem does not seem to occur on amd64 or arm64. Openscad doesn't build
on armhf, so not sure if the problem in mawk is specific to i386 or may be
specific to 32-bit for example.

-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 5.10.0-8-amd64 (SMP w/8 CPU threads)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to C.UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect

Versions of packages mawk depends on:
ii  libc6  2.38-13

mawk recommends no packages.

mawk suggests no packages.

-- no debconf information

Reply via email to