GNU bug report logs - #73405
wrap-program should use the basename of $0 as arg0

Previous Next

Package: guix;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Sat, 21 Sep 2024 05:55:02 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 73405 in the body.
You can then email your comments to 73405 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#73405; Package guix. (Sat, 21 Sep 2024 05:55:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Sat, 21 Sep 2024 05:55:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: bug-guix <bug-guix <at> gnu.org>
Subject: wrap-program should use the basename of $0 as arg0
Date: Sat, 21 Sep 2024 14:51:43 +0900
Hi,

I believe wrap-program should be using

--8<---------------cut here---------------start------------->8---
exec -a ${0##*/} ...
--8<---------------cut here---------------end--------------->8---

instead of

--8<---------------cut here---------------start------------->8---
exec -a "$0" ...
--8<---------------cut here---------------end--------------->8---

as the later will use the full file name of the command
(/gnu/store/.../bin/something) instead of just the command name, which
is more conventional.

I made this discovery while investigating a segfault that occured in a
wrapped 'cling'; adjusting the wrapper script to read as:

--8<---------------cut here---------------start------------->8---
#!/gnu/store/3jhfhxdf6v5ms10x5zmnl166dh3yhbr1-bash-minimal-5.1.16/bin/bash
exec -a ${0##*/} "/gnu/store/0ccm05058yjd5qi8hcdr70ymhf9q6cc2-cling-1.1/bin/.cling-real" "$@"
--8<---------------cut here---------------end--------------->8---

where the value of -a becomes 'cling' instead of its full file name
resolved the issue. The original wrapper reads like:

--8<---------------cut here---------------start------------->8---
#!/gnu/store/3jhfhxdf6v5ms10x5zmnl166dh3yhbr1-bash-minimal-5.1.16/bin/bash
exec -a "$0" "/gnu/store/l8875yavr1nls7n3i3yx8ah0s1lasn43-cling-1.1/bin/.cling-real" "$@"
--8<---------------cut here---------------end--------------->8---

It's probably rare that this "problem" would manifest itself so
critically, but still, I think it'd be good to adjust our wrap-program
procedure.  I'll send a patch.

-- 
Thanks,
Maxim




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Sat, 22 Mar 2025 22:36:01 GMT) Full text and rfc822 format available.

Notification sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
bug acknowledged by developer. (Sat, 22 Mar 2025 22:36:02 GMT) Full text and rfc822 format available.

Message #10 received at 73405-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 73416-done <at> debbugs.gnu.org, Andreas Enge <andreas <at> enge.fr>,
 73405-done <at> debbugs.gnu.org
Subject: Re: bug#73416: [PATCH core-updates] build: Set $0 to basename of
 command in `wrap-program'.
Date: Sat, 22 Mar 2025 23:35:28 +0100
Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:

> * guix/build/utils.scm (wrap-program): Set the value of the -a option of
> `exec' in the wrapper to ${0##*/} instead of $0, to use its base name instead
> of the complete file name.
>
> Fixes: https://issues.guix.gnu.org/73405
> Change-Id: Iec5984d4d934c8df88a90ff653947f7d07413ae4

Applied to ‘core-packages-team’, thanks!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 20 Apr 2025 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 19 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.