Skip to content

Revert a bug from c1f4b7c where CRAM aux tags were not compressed.#1729

Merged
daviesrob merged 1 commit into
samtools:developfrom
jkbonfield:cram_aux_compression
Jan 16, 2024
Merged

Revert a bug from c1f4b7c where CRAM aux tags were not compressed.#1729
daviesrob merged 1 commit into
samtools:developfrom
jkbonfield:cram_aux_compression

Conversation

@jkbonfield

Copy link
Copy Markdown
Contributor

In an attempt to fix memory leaks during encode of malformed CRAM data, that lead to bailing out early, we attempted to get everything to a uniform state as soon as possible. Specifically s->aux_blocks get migrated to s->blocks earlier, so if we bail out we don't have the decision to make as to which bit of memory needs freeing.

That worked, but unfortunately I forgot that the compression is applied to s->aux_blocks and not s->blocks for auxiliary tags, so moving the blocks earlier gives uncompressed blocks in CRAM. The format is valid and all tests pass, but it's overly large for obvious reasons.

Sadly this is a rather serious bug caused by an attempt to fix a really minor bug.

Fixes samtools/samtools#1968

In an attempt to fix memory leaks during encode of malformed CRAM
data, that lead to bailing out early, we attempted to get everything
to a uniform state as soon as possible.  Specifically s->aux_blocks
get migrated to s->blocks earlier, so if we bail out we don't have the
decision to make as to which bit of memory needs freeing.

That worked, but unfortunately I forgot that the compression is
applied to s->aux_blocks and not s->blocks for auxiliary tags, so
moving the blocks earlier gives uncompressed blocks in CRAM.  The
format is valid and all tests pass, but it's overly large for obvious
reasons.

Sadly this is a rather serious bug caused by an attempt to fix a
really minor bug.

Fixes samtools/samtools#1968
@daviesrob daviesrob merged commit 31e5a5f into samtools:develop Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Samtools 1.19 bam-cram conversion produce cram bigger than bam

2 participants