Repository navigation
Conversation
IndexedReader was using >= 0, but htslib's bcf_sr_add_reader returns 1 on success and 0 on failure. Thus, a failed from_url open dereferenced a NULL header and crashed. Similar issue in tbx::Reader calling hts_get_format on a NULL hts_open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I hit this while streaming a VCF from a
gs://bucket in a Jupyter Lab notebook. A failed open didn't return an error. It segfaulted and killed the notebook kernel.The cause is in
IndexedReader::new. htslib'sbcf_sr_add_readerreturns 1 on success and 0 on failure. This code used>= 0, treated failure as success, and then dereferenced the NULL header.from_pathnever hits it because it checks existence in Rust first;from_urldoes.SyncedReader::add_readerin this crate already checksres == 0. This PR does the same, and also null-checkshts_openintbx::Readerbeforehts_get_format.I've added two tests (
IndexedReader::from_urlandtbx::Reader::from_url) on a missingfile://path. Before the fix, they abort with anull pointer dereferenceerror. After the fix, they now returnErras expected.(Unrelated one-liner:
header_hashmap.get("SQ")so the test crate compiles on current rustc.)