#1 Bug fixes (patch to 11 Jan 2008 CVS)

closed-accepted
nobody
None
5
2008-03-31
2008-01-11
James Bonfield
No

This fixes a few code issues (bugs and some memory handling), plus bug-fixes for version 1.3 support by enforcing big-endian read and writes.

Patch notes:

Makefile
replaced CPPFLAGS and LDFLAGS for io_lib with io_lib-config
queries. This is gmake specific though and my code is still
relying on a fixed pathname for an io_lib installation.

I think "as is" this change isn't suitable, but I include it
for completeness and to demonstrate the official way to link
against io_lib.

SRF_Container.cc
SRF_Read.cc
SRF_ReadSet.cc
Force big-endian format, as per RQ-7. Previously the code
generated malformed SRF files on little-endian systems (eg
Intel/AMD based PCs).

SRF_Container.cc
SRF_Container.hh
SRF_Read.cc
SRF_Read.hh
SRF_ReadSet.cc
SRF_ReadSet.hh
Replaced ztrHeader with a std::string. I'm not sure that's the
optimal type for binary blobs of fata , but it works
sufficiently.

The reason for this is that the ztr_t struct in memory isn't
necessarily the same layout as on disk. Furthermore the
headerBlob in DBH is not necessary just the ZTR header and it
may contain common chunks too. (In my solexa2srf code this is
exploited too to put common HUFF chunks there.)

Hence I treat it as a string and paste the two halves together
when decoding the ZTR file. This also means SRF_Read::populate
has an additional field for the header blob.

SRF_Read.cc
Fixed a memory leak. ztr is now deleted usign delete_ztr
instead which destroys the internal data structures as well as
the ztr malloced item itself.

SRF_Read.cc
Minor output formatting changes, including the trace data now
too. For testing/debugging purposes.

SRF_Ztr.cc
Fixed uninitialised memory accesses and rogue allocations.
Eof() only returns true when we've attempted to read *past*
the end of a stream and not when we are *at* the end. Hence it
always attempted to decode one chunk too many and due to lack
of checking that the initial read worked this meant it
malloced an arbitrary amount of data.

On my test machine it rapidly hit 510Gb of virtual memory -
fortunately only virtual :-)

I've also removed a memory leak by setting chunk->ztr_owns.
This is a new feature added to the recent io_lib releases to
allow data to be shared between multiple ztr creations (for
efficient caching of deflate_interlaced tables).

SRF_Container.cc
SRF_Read.cc
SRF_ReadSet.cc
Replaced "delete foo" with "delete [] foo" where foo had been
allocated via the pascal string functions using new [].

SRF_util.cc
Fixed bug in SRF_cStrToPascalStr where newStr needed to be one
longer (to hold the C nul char).

testWrite.cc
Allowed it to read a named file on the command line instead
of from stdin. This is purely my own preference to allow it to
be easily debugged via valgrind. So not an important change.

Also updated the newReadSet.setup() call to pass over a blank
string for the ztrHeader.

Discussion

  • James Bonfield
    James Bonfield
    2008-01-11

    patch1

     
    Attachments
  • Asim
    Asim
    2008-03-31

    Logged In: YES
    user_id=1765186
    Originator: NO

    These changes have been applied to the code.

     
  • Asim
    Asim
    2008-03-31

    • status: open --> closed
     
  • Asim
    Asim
    2008-03-31

    • status: closed --> closed-accepted