Bug 196929 - ar: fatal: Numeric user ID too large
Summary: ar: fatal: Numeric user ID too large
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: toolchain
Depends on:
Blocks:
 
Reported: 2015-01-20 12:11 UTC by napetrov
Modified: 2015-09-25 00:26 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description napetrov 2015-01-20 12:11:27 UTC
ar failing on files with long UID. 

[root@hostname ~]# echo 123 > tst.txt
[root@hostname ~]# chown napetrov tst.txt
[root@hostname ~]# ls -anl tst.txt
-rw-r--r--  1 11299695  0  4 Dec  9 12:04 tst.txt
[root@hostname ~]# ar -rc test.a tst.txt
ar: fatal: Numeric user ID too large
Comment 1 Ed Maste freebsd_committer freebsd_triage 2015-01-20 16:10:51 UTC
The ar format only allows 6 decimal characters for the uid/gid, so there's no way to encode your uid. Using the -D option (deterministic mode) should avoid this issue, because it replaces the time, uid and gid fields with 0.

Can you see how GNU ar (from the binutils port/pkg) handles this case?
Comment 2 napetrov 2015-01-21 13:59:14 UTC
GNU ar just store first 6 characters with no errors:

[root@BSD ~]# echo 123 > tst.txt
[root@BSD ~]# chown napetrov tst.txt
[root@BSD ~]# ls -anl tst.txt
-rw-r--r--  1 11299695  0  4 Dec 10 14:15 tst.txt
[root@BSD ~]# /usr/local/bin/ar -rc test.a tst.txt
[root@BSD ~]# /usr/local/bin/ar -V
GNU ar (GNU Binutils) 2.25
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
[root@BSD ~]# strings test.a
!<arch>
tst.txt/        1418195726  1129960     100644  4         `
[root@BSD ~]# cat test.a | od -c
0000000    !   <   a   r   c   h   >  \n   t   s   t   .   t   x   t   /
0000020                                    1   4   1   8   1   9   5   7
0000040    2   6           1   1   2   9   9   6   0
0000060    1   0   0   6   4   4           4
0000100            `  \n   1   2   3  \n
0000110
Comment 3 Glen Barber freebsd_committer freebsd_triage 2015-07-08 13:13:53 UTC
Ed, I've verified this is still an issue on 11-CURRENT.  Since you've been touching ar(1) lately, would you mind taking a look?

root@nucleus:~ # cat tst.txt 
123
root@nucleus:~ # chown 123456789:123456789 tst.txt 
root@nucleus:~ # ll
total 5
-rw-r--r--  1 123456789  123456789  4 Jul  8 09:07 tst.txt
root@nucleus:~ # ar -rc tst.a tst.txt 
ar: fatal: Numeric user ID too large
Comment 4 Ed Maste freebsd_committer freebsd_triage 2015-07-08 13:34:13 UTC
(In reply to Glen Barber from comment #3)

The ar format cannot store UIDs longer than 6 decimal digits. This needs to be addressed by using ar -D, which I see is set by default in ARFLAGS. I would like to enable deterministic mode directly in ar, but only after we add the -U flag to disable it.

ELF Tool Chain's ar(1) is a cousin of the one in the FreeBSD tree, and I've submitted a ticket to track this there: https://sourceforge.net/p/elftoolchain/tickets/500/

The likely path forward is for -U to be added to ELF Tool Chain's ar first, and then migrate to it in a subsequent ELF Tool Chain update in FreeBSD.

GNU ar's behaviour is a bug; storing the first 6 digits of a longer UID is bogus.
Comment 5 commit-hook freebsd_committer freebsd_triage 2015-07-24 17:47:30 UTC
A commit references this bug:

Author: emaste
Date: Fri Jul 24 17:46:44 UTC 2015
New revision: 285844
URL: https://svnweb.freebsd.org/changeset/base/285844

Log:
  ar: add -U (unique) option to disable -D (deterministic) mode

  This is required in order for us to support deterministic mode by
  default.  If multiple -D or -U options are specified on the command
  line, the final one takes precedence.  GNU ar also uses -U for this.

  An equivalent change will be applied to ELF Tool Chain's version of ar.

  PR:		196929
  MFC after:	1 month
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D3175

Changes:
  head/usr.bin/ar/ar.1
  head/usr.bin/ar/ar.c
Comment 6 Ed Maste freebsd_committer freebsd_triage 2015-07-24 19:03:22 UTC
Enabling -D mode by default is in review: https://reviews.freebsd.org/D3190
Comment 7 commit-hook freebsd_committer freebsd_triage 2015-07-29 13:37:19 UTC
A commit references this bug:

Author: emaste
Date: Wed Jul 29 13:36:19 UTC 2015
New revision: 286010
URL: https://svnweb.freebsd.org/changeset/base/286010

Log:
  ar: enable deterministic mode by default

  Ar cannot handle UIDs with more than 6 digits, and storing the mtime,
  uid, gid and mode provides little to negative value anyhow for ar's
  uses. Turn on deterministic (-D) mode by default; it can be disabled by
  the user with -U.

  PR:		196929
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D3190

Changes:
  head/usr.bin/ar/ar.1
  head/usr.bin/ar/ar.c
Comment 8 commit-hook freebsd_committer freebsd_triage 2015-08-31 17:30:29 UTC
A commit references this bug:

Author: emaste
Date: Mon Aug 31 17:30:14 UTC 2015
New revision: 287326
URL: https://svnweb.freebsd.org/changeset/base/287326

Log:
  MFC r285844: ar: add -U (unique) option to disable -D (deterministic) mode

  This is required in order for us to support deterministic mode by
  default.  If multiple -D or -U options are specified on the command
  line, the final one takes precedence.  GNU ar also uses -U for this.

  PR:		196929
  Sponsored by:	The FreeBSD Foundation

Changes:
_U  stable/10/
  stable/10/usr.bin/ar/ar.1
  stable/10/usr.bin/ar/ar.c
Comment 9 commit-hook freebsd_committer freebsd_triage 2015-09-25 00:24:19 UTC
A commit references this bug:

Author: emaste
Date: Fri Sep 25 00:23:37 UTC 2015
New revision: 288202
URL: https://svnweb.freebsd.org/changeset/base/288202

Log:
  MFC r286010: ar: enable deterministic mode by default

  Ar cannot handle UIDs with more than 6 digits, and storing the mtime,
  uid, gid and mode provides little to negative value anyhow for ar's
  uses. Turn on deterministic (-D) mode by default; it can be disabled by
  the user with -U.

  Also MFC follow-on fixes in r286024 and r287324.

  PR:		196929
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation

Changes:
_U  stable/10/
  stable/10/usr.bin/ar/ar.1
  stable/10/usr.bin/ar/ar.c
Comment 10 Ed Maste freebsd_committer freebsd_triage 2015-09-25 00:26:51 UTC
Deterministic mode is now enabled by default in HEAD and stable/10.