[haiku-bugs] Re: [Haiku] #11306: "package add" no longer works

  • From: "mmlr" <trac@xxxxxxxxxxxx>
  • Date: Wed, 08 Oct 2014 21:57:41 -0000

#11306: "package add" no longer works
--------------------------------+----------------------------
   Reporter:  ttcoder           |      Owner:  bonefish
       Type:  bug               |     Status:  new
   Priority:  normal            |  Milestone:  R1
  Component:  Kits/Package Kit  |    Version:  R1/Development
 Resolution:                    |   Keywords:
 Blocked By:                    |   Blocking:
Has a Patch:  0                 |   Platform:  All
--------------------------------+----------------------------

Comment (by mmlr):

 I've investigated this and my conclusion is as follows:

 When PackageFileHeapWriter tries to unwrite the last partial chunk in
 PackageFileHeapWriter::_UnwriteLastPartialChunk() it uses ReadData() which
 in turn calls into PackageFileHeapWriter::ReadAndDecompressChunk() with
 the index argument set to the last, partial, chunk (0 in case of the
 provided test case). Since it is the last chunk, it is assumed to be
 pending (as it would be once the last partial chunk was unwritten), so the
 pending buffer (which is yet to be filled) is copied to the uncompressed
 buffer instead of decompressing the actual last chunk. The pending buffer
 ends up containing nulls instead of the data of the last partial chunk.

 Since the .PackageInfo is the only content of the package at this point,
 it fully resides in the last partial chunk and is therefore completely
 lost. Since the last chunk is lost in any case, using {{{package add}}}
 should always be corrupting the package, even when not failing to read the
 .PackageInfo (i.e. when there's enough additional data so that
 .PackageInfo doesn't reside in the last partial chunk).

 I'm attaching a workaround that uses a flag to signify whether we are
 unwriting the last partial chunk so that
 PackageFileHeapWriter::ReadAndDecompressChunk() uncompresses the last
 chunk instead of returning the (yet unfilled) pending buffer. I can't
 really tell how to fix this properly.

--
Ticket URL: <https://dev.haiku-os.org/ticket/11306#comment:8>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: