Incorrect evaluation of expr

Bug #2112445 reported by Heinrich Schuchardt
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
coreutils-from (Ubuntu)
Invalid
Undecided
Unassigned
qemu (Ubuntu)
Invalid
Undecided
Unassigned
rust-coreutils (Debian)
New
Unknown
rust-coreutils (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

I have installed rust-coreutils 0.0.30-2.

I have created a symbolic link /usr/bin/expr => /usr/lib/cargo/bin/coreutils/expr.

When executing the appended script test.sh it does not find a space between words.

With /usr/bin/expr => /usr/bin/gnuexpr the script finds a space.

My expectation is that both binaries should be equivalent.

Best regards

Heinrich

Revision history for this message
Heinrich Schuchardt (xypron) wrote :
Revision history for this message
Christian Ehrhardt (paelzer) wrote :

Thank you for filing this, I can confirm this hits me as well and I can reproduce the above in questing containers.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in rust-coreutils (Ubuntu):
status: New → Confirmed
Changed in rust-coreutils (Ubuntu):
milestone: none → ubuntu-25.10
Revision history for this message
Christian Ehrhardt (paelzer) wrote :

Adding a qemu bug task as it is affected by this due to [1] related FTFBS log [2] is sadly very unhelpful and not pointing much at the root cause. Thanks @xypron for co-debugging this!

I'm trying to add a temporary fix to qemu by depending on coreutils-from-gnu, if there is a better recommended way to temp-overcome these let me know.

[1]: https://sources.debian.org/src/qemu/1:10.0.2+ds-1/debian/rules/?hl=7#L141
[2]: https://launchpadlibrarian.net/797329880/buildlog_ubuntu-questing-amd64.qemu_1%3A10.0.2+ds-1ubuntu1~questingppa1_BUILDING.txt.gz

Changed in qemu (Ubuntu):
status: New → Invalid
Revision history for this message
Sylvestre Ledru (sylvestre) wrote :
Revision history for this message
Christian Ehrhardt (paelzer) wrote :

For the original problem as spotted in qemu builds Heinrich (thanks again!) came up with:

From:
  len2=$$(($${#list}/2));
  if [ $$len2 -gt 36 ]; then \
     while expr substr "$$list" $$len2 1 != " " >/dev/null; do len2=$$(($$len2+1)); done; \
     list="$$(expr substr "$$list" 1 $$(($$len2-1)))\$${Newline} $$(expr substr "$$list" $$(($$len2+1)) $$len2)"; \
  fi;

To:
  echo "$list" | fold -s -w 36 >> debian/qemu.subst

That is more the tool that is meant to do that and has the added benefit of working with the rust coreutils already. I tested it with the lists we get on armhf (short) and others (longer and broken up) - AFAICS it works. @Heinich - I think it makes sense to submit that to Debian, do you want to or should I?

Changed in rust-coreutils (Debian):
status: Unknown → New
Revision history for this message
Julian Andres Klode (juliank) wrote :

It seems qemu built fine in questing-proposed 9 hours ago, does this need a workaround? If nothing else breaks, I prefer to keep expr pointed to the rust versions.

Changed in coreutils-from (Ubuntu):
status: New → Incomplete
Revision history for this message
Christian Ehrhardt (paelzer) wrote :

Hi Julian,
it only built by an aggressive push :-)

We essentially removed the offending lines losing some (not too critical things).
We are waiting for this to be fixed to bring it back.

Heinrich is discussing with Debian about an alternative, but that hasn't landed yet.
Once it does we do not need expr there anymore and we'd be fine even without a fix of this here (but others might still stumble over the same).

Changed in coreutils-from (Ubuntu):
status: Incomplete → New
Revision history for this message
Christian Ehrhardt (paelzer) wrote :
Revision history for this message
Heinrich Schuchardt (xypron) wrote :

Upstream has merged
6049bc091ae0 (expr: fix substr parsing)
https://github.com/uutils/coreutils/pull/8158

no longer affects: gnupg2 (Ubuntu)
Revision history for this message
Julian Andres Klode (juliank) wrote :

Fixed in 0.1.0+git20250711.2ba3a33-0ubuntu1 which I can't yet upload as messages are broken due to the translation effort.

Changed in rust-coreutils (Ubuntu):
status: Confirmed → In Progress
Changed in rust-coreutils (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package rust-coreutils - 0.1.0+git20250711.2ba3a33-0ubuntu1

---------------
rust-coreutils (0.1.0+git20250711.2ba3a33-0ubuntu1) questing; urgency=medium

  * New upstream git commit 0.1.0+git20250711.2ba3a33
    - Fix 'od' invalid handling of non ascii chars (LP: #2114827)
    - Fix `cp -a` fails to copy symlink to directory (LP: #2116859)
    - Fix dpkg-source fails to unpack broken symlink (LP: #2116886)
    - Fix Incorrect evaluation of expr (LP: #2112445)
    - Fix cat doesn't handle EPERM (LP: #2112552)
    - Fix /bin/stty: invalid argument 'sane' (LP: #2113983)
    - Fix tee is buffered (LP: #2114706)
    - Fix rm of long paths (LP: #2114886)
    - Fix ls doesn't include acl "+" info on symlink (LP: #2114887)
    - Fix fold: failed to read line: stream did not contain valid UTF-8
      (LP: #2114970)
    - Fix gpgrt-config invalid output due to rust-coreutils "expr"
      (LP: #2115147)
    - Fix `cp --no-dereference --parents` where source is a symlink to
      a directory (LP: #2116572)
    - Internationalization and French translations for a lot of stuff
  * Install locales
  * d/patches/Setup-localization-for-utility-symlinks.patch: Setup the
    localization when invoked via symlinks

 -- Julian Andres Klode <email address hidden> Mon, 21 Jul 2025 12:48:46 +0200

Changed in rust-coreutils (Ubuntu):
status: Fix Committed → Fix Released
Changed in coreutils-from (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.