/usr/bin/tar creates invalid lib file

Boris Samorodov bsam at passap.ru
Sun Mar 25 19:01:59 UTC 2012


25.03.2012 21:53, Tim Kientzle пишет:
> 
> On Mar 25, 2012, at 5:53 AM, Boris Samorodov wrote:
> 
>> On 24.03.2012 21:00, Tim Kientzle wrote:
>>>
>>> On Mar 23, 2012, at 9:51 PM, Boris Samorodov wrote:
>>>
>>> Can you send me the output of:
>>>
>>> tar -cvf /tmp/test.tar /usr/ports/devel/nspr/work/nspr-4.9/mozilla/nsprpub/build/dist/lib/../../pr/src/./libnspr4.so.1
>>>
>>> (A tar archive containing only that one source file.)
>>>
>>> This looks similar to a bug that we found in libarchive recently
>>> I didn't think that bug impacted FreeBSD, but I may have been
>>> wrong….  if it did, it will be obvious from the structure of the
>>> created archive.
>>
>> The following file is extracted after tarring:
>> -----
>> % hd libnspr4.so.1
>> 00000000  32 0a 30 0a 30 0a 32 34  31 39 37 31 0a 30 0a 00 |2.0.0.241971.0..|
>> 00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 |................|
>> *
>> 00000200
>> -----
>>
>> The tar file itself attached (3KB in length).
> 
> Ugh.  I'll probably need your help to diagnose this more precisely.
> 
> Here is the root problem:   tar thinks this is a sparse file
> with nothing in it.    On FreeBSD, bsdtar now uses
> lseek(SEEK_HOLE) to identify holes in the file.  For
> some reason, bsdtar is storing this file as just one big hole.
> 
> There are a lot of things here that don't make sense:
> 
>   * The extracted file should be all zero bytes.  (The 2.0.0.241971.0. is the sparse file map, it's not really part of the file.)  How are you extracting this?

I used misc/mc to walk through the filesystem of the tar archive
and then just copy <F5> the library to an existing file system.

OK, you are right. Seems that mc has made a joke on me. When
I extract the file at command line it consists of zeros:
-----
% tar xvf /tmp/test.tar --strip-components 16
% ls -l
total 1
-rwxr-xr-x  1 bsam  wheel  241971 24 мар 08:48 libnspr4.so.1
% hd libnspr4.so.1
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
|................|
*
0003b130
-----

>   * Can you run the tar command under truss or ktrace and look for calls to lseek()?  That would help verify that this is really a tar bug and not a filesystem or kernel bug.

Interesting... I'll create three tar archives (without truss,
with truss and with kdump):
-----
% ls -l /tmp/test/
total 0
% sudo tar -cvf /tmp/test/no-truss.tar
/usr/ports/devel/nspr/work/nspr-4.9/mozilla/nsprpub/build/dist/lib/../../pr/src/./libnspr4.so.1
[...]
% sudo truss tar -cvf /tmp/test/truss.tar
/usr/ports/devel/nspr/work/nspr-4.9/mozilla/nsprpub/build/dist/lib/../../pr/src/./libnspr4.so.1
[...]
% sudo ktrace tar -cvf /tmp/test/ktrace.tar
/usr/ports/devel/nspr/work/nspr-4.9/mozilla/nsprpub/build/dist/lib/../../pr/src/./libnspr4.so.1
% ls -l /tmp/test
total 248
-rw-r--r--  1 root  wheel    3072 25 мар 22:47 ktrace.tar
-rw-r--r--  1 root  wheel    3072 25 мар 22:46 no-truss.tar
-rw-r--r--  1 root  wheel  243712 25 мар 22:47 truss.tar
-----

Seems that we get a good tar archive while using truss!

Lets see what kdump says. The relevant last part is attached.

> I'll spend some time today to see if I can reproduce the problem here.

Thanks. Let me know if I can help you here.

-- 
WBR, Boris Samorodov (bsam)
FreeBSD Committer, http://www.FreeBSD.org The Power To Serve
-------------- next part --------------
  4379 bsdtar   GIO   fd 5 read 537 bytes
       "# $FreeBSD: head/etc/group 218046 2011-01-28 22:28:12Z pjd $
	#
	wheel:*:0:root
	daemon:*:1:
	kmem:*:2:
	sys:*:3:
	tty:*:4:
	operator:*:5:root,bsam"
  4379 bsdtar   RET   read 537/0x219
  4379 bsdtar   CALL  close(0x5)
  4379 bsdtar   RET   close 0
  4379 bsdtar   CALL  madvise(0x3414f000,0x8000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  __acl_get_link(0x34016100,ACL_TYPE_ACCESS,0x34148000)
  4379 bsdtar   NAMI  "/usr/ports/devel/nspr/work/nspr-4.9/mozilla/nsprpub/build/dist/lib/../../pr/src/./libnspr4.so.1"
  4379 bsdtar   RET   __acl_get_link -1 errno 22 Invalid argument
  4379 bsdtar   CALL  extattr_list_link(0x34016100,0x1,0,0)
  4379 bsdtar   NAMI  "/usr/ports/devel/nspr/work/nspr-4.9/mozilla/nsprpub/build/dist/lib/../../pr/src/./libnspr4.so.1"
  4379 bsdtar   RET   extattr_list_link 0
  4379 bsdtar   CALL  pathconf(0x34016100,0x15)
  4379 bsdtar   NAMI  "/usr/ports/devel/nspr/work/nspr-4.9/mozilla/nsprpub/build/dist/lib/../../pr/src/./libnspr4.so.1"
  4379 bsdtar   RET   pathconf 512/0x200
  4379 bsdtar   CALL  open(0x34016100,0x4<O_NONBLOCK>,<unused>0)
  4379 bsdtar   NAMI  "/usr/ports/devel/nspr/work/nspr-4.9/mozilla/nsprpub/build/dist/lib/../../pr/src/./libnspr4.so.1"
  4379 bsdtar   RET   open 5
  4379 bsdtar   CALL  lseek(0x5,0,SEEK_SET,0x3)
  4379 bsdtar   RET   lseek 0
  4379 bsdtar   CALL  lseek(0x5,0,SEEK_SET,0x4)
  4379 bsdtar   RET   lseek 0
  4379 bsdtar   CALL  lseek(0x5,0,SEEK_SET,0x3)
  4379 bsdtar   RET   lseek -1 errno 6 Device not configured
  4379 bsdtar   CALL  close(0x5)
  4379 bsdtar   RET   close 0
  4379 bsdtar   CALL  write(0x2,0x82bfe438,0x5)
  4379 bsdtar   GIO   fd 2 wrote 5 bytes
       "tar: "
  4379 bsdtar   RET   write 5
  4379 bsdtar   CALL  write(0x2,0x82bfe438,0x26)
  4379 bsdtar   GIO   fd 2 wrote 38 bytes
       "Removing leading '/' from member names"
  4379 bsdtar   RET   write 38/0x26
  4379 bsdtar   CALL  write(0x2,0x33fce04f,0x1)
  4379 bsdtar   GIO   fd 2 wrote 1 byte
       "
       "
  4379 bsdtar   RET   write 1
  4379 bsdtar   CALL  write(0x2,0x82bfe6f8,0x60)
  4379 bsdtar   GIO   fd 2 wrote 96 bytes
       "a usr/ports/devel/nspr/work/nspr-4.9/mozilla/nsprpub/build/dist/lib/../../pr/src/./libnspr\
	4.so.1"
  4379 bsdtar   RET   write 96/0x60
  4379 bsdtar   CALL  open(0x34016100,0<O_RDONLY>,<unused>0x33cdf550)
  4379 bsdtar   NAMI  "/usr/ports/devel/nspr/work/nspr-4.9/mozilla/nsprpub/build/dist/lib/../../pr/src/./libnspr4.so.1"
  4379 bsdtar   RET   open 5
  4379 bsdtar   CALL  read(0x5,0x3403b000,0x14000)
  4379 bsdtar   GIO   fd 5 read 4096 bytes
       0x0000 7f45 4c46 0101 0109 0000 0000 0000 0000 0300 0300 0100  |.ELF..................|
       0x0016 0000 208a 0000 3400 0000 480b 0300 0000 0000 3400 2000  |.. ...4...H.......4. .|
       0x002c 0400 2800 1b00 1800 0100 0000 0000 0000 0000 0000 0000  |..(...................|
       0x0042 0000 98e9 0200 98e9 0200 0500 0000 0010 0000 0100 0000  |......................|
       0x0058 00f0 0200 00f0 0200 00f0 0200 1010 0000 6827 0000 0600  |................h'....|
       0x006e 0000 0010 0000 0200 0000 90f3 0200 90f3 0200 90f3 0200  |......................|
       0x0084 d000 0000 d000 0000                                     |........|

  4379 bsdtar   RET   read 81920/0x14000
  4379 bsdtar   CALL  read(0x5,0x3403b000,0x14000)
  4379 bsdtar   GIO   fd 5 read 4096 bytes
       0x0000 e820 50ff ff81 c34b b501 0083 e003 0f85 7e00 0000 c1fe  |. P....K........~.....|
       0x0016 0285 f689 75f0 7443 8bbb 5020 0000 85ff 0f84 7f00 0000  |....u.tC..P ..........|
       0x002c f645 f001 7513 d17d f074 2a8b 3785 f674 2f89 f7f6 45f0  |.E..u..}.t*.7..t/...E.|
       0x0042 0174 ed8b 45ec 89fa e851 fbff ff89 c68b 45ec e847 fdff  |.t..E....Q......E..G..|
       0x0058 ffd1 7df0 8975 ec75 d68b 45ec 83c4 0c5b 5e5f 5dc3 8b83  |..}..u.u..E....[^_]...|
       0x006e 1417 0000 8904 24e8 1a3f ffff 8b37 85f6 7456 8b83 1417  |......$..?...7..tV....|
       0x0084 0000 89f7 8904 24e8                                     |......$.|

  4379 bsdtar   RET   read 81920/0x14000
  4379 bsdtar   CALL  read(0x5,0x3403b000,0x14000)
  4379 bsdtar   GIO   fd 5 read 4096 bytes
       0x0000 897c 2404 8904 24ff 93b4 0a00 0085 c089 c678 228b 4d0c  |.|$...$..........x".M.|
       0x0016 85c9 740c 8b55 0c89 f8e8 7cf4 ffff 89c6 89f0 8b5d f48b  |..t..U....|........]..|
       0x002c 75f8 8b7d fc89 ec5d c3e8 fa02 feff 8b00 8904 24e8 3c0d  |u..}...]..........$.<.|
       0x0042 0000 ebe0 8d76 008d bc27 0000 0000 5589 e583 ec78 895d  |.....v...'....U....x.]|
       0x0058 f48b 4508 e8c4 0ffe ff81 c3ef 7400 0089 7dfc 8d7d 9489  |..E.........t...}..}..|
       0x006e 75f8 897c 2404 8904 24e8 f8fb fdff 85c0 89c6 7822 8b45  |u..|$...$.........x".E|
       0x0084 0c85 c074 0c8b 550c                                     |...t..U.|

  4379 bsdtar   RET   read 78131/0x13133
  4379 bsdtar   CALL  read(0x5,0x3403b000,0x14000)
  4379 bsdtar   GIO   fd 5 read 0 bytes
       ""
  4379 bsdtar   RET   read 0
  4379 bsdtar   CALL  close(0x5)
  4379 bsdtar   RET   close 0
  4379 bsdtar   CALL  write(0x2,0x33fce04f,0x1)
  4379 bsdtar   GIO   fd 2 wrote 1 byte
       "
       "
  4379 bsdtar   RET   write 1
  4379 bsdtar   CALL  fchdir(0x4)
  4379 bsdtar   RET   fchdir 0
  4379 bsdtar   CALL  close(0x4)
  4379 bsdtar   RET   close 0
  4379 bsdtar   CALL  write(0x3,0x340a9800,0xc00)
  4379 bsdtar   GIO   fd 3 wrote 3072 bytes
       "ports/devel/nspr/work/nspr-4.9/mozilla/nsprpub/build/dist/lib/../../pr/src/./PaxHeader/lib\
	nspr4.so.1000755 \000000000 \000000000 \00000000000427 1173"
  4379 bsdtar   RET   write 3072/0xc00
  4379 bsdtar   CALL  close(0x3)
  4379 bsdtar   RET   close 0
  4379 bsdtar   CALL  madvise(0x340ef000,0x2000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x340a9000,0x3000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x340a7000,0x1000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x3403b000,0x14000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x340ed000,0x2000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x34060000,0x1000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x34050000,0x1000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x34147000,0x1000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x3404f000,0x1000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x3402c000,0x1000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x341a7000,0x1000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x34016000,0x1000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  madvise(0x34012000,0x3000,MADV_FREE)
  4379 bsdtar   RET   madvise 0
  4379 bsdtar   CALL  sigprocmask(SIG_BLOCK,0x33c6c270,0x82bfea68)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_SETMASK,0x33c6c284,0)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_BLOCK,0x33c6c270,0x82bfe1e8)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_SETMASK,0x33c6c284,0)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_BLOCK,0x33c6c270,0x82bfe1e8)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_SETMASK,0x33c6c284,0)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_BLOCK,0x33c6c270,0x82bfe1e8)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_SETMASK,0x33c6c284,0)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_BLOCK,0x33c6c270,0x82bfe1e8)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_SETMASK,0x33c6c284,0)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_BLOCK,0x33c6c270,0x82bfe1e8)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_SETMASK,0x33c6c284,0)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_BLOCK,0x33c6c270,0x82bfe1e8)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_SETMASK,0x33c6c284,0)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_BLOCK,0x33c6c270,0x82bfe1e8)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_SETMASK,0x33c6c284,0)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_BLOCK,0x33c6c270,0x82bfe1e8)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  sigprocmask(SIG_SETMASK,0x33c6c284,0)
  4379 bsdtar   RET   sigprocmask 0
  4379 bsdtar   CALL  exit(0)


More information about the freebsd-current mailing list