-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bit packing inputs with 256 symbols do not disable bit packing #65
Comments
I think this was probably something that I tightened up in the spec with an explicit "not permitted to have nsym > 16 or nsym == 0" statement at a later stage. The bug is really one of not knowing how best to deal with errors; eg failed to allocate memory (hard error) vs inappropriate data (soft error). I think I took the wrong choice in making it return a buffer in the latter case, as it's both wasteful of CPU cycles and also punts the error handling elsewhere. Specifically here: htscodecs/htscodecs/rANS_static4x16pr.c Line 1267 in 843d4f6
However given the handling of the NULL case anyway, Thanks for the bug report. |
Previously when too many symbols were present, we still returned packed data but with 1 byte per symbol. It was then up to the caller to reject this as inappropriate use of pack. This meant that hts_pack was a transparent transform that always gives back something even if it's actually just growing the data by 1 byte. However the CRAMcodecs spec states this scenario is illegal. The checks in rANS_static4x16pr.c were bugged for nsym==256 as there wasn't a check of "|| out[c_meta_len] == 0", but now it's a moot point as NULL will be returned. Fixes samtools#65
Previously when too many symbols were present, we still returned packed data but with 1 byte per symbol. It was then up to the caller to reject this as inappropriate use of pack. This meant that hts_pack was a transparent transform that always gives back something even if it's actually just growing the data by 1 byte. However the CRAMcodecs spec states this scenario is illegal. The checks in rANS_static4x16pr.c were bugged for nsym==256 as there wasn't a check of "|| out[c_meta_len] == 0", but now it's a moot point as NULL will be returned. Fixes samtools#65
Previously when too many symbols were present, we still returned packed data but with 1 byte per symbol. It was then up to the caller to reject this as inappropriate use of pack. This meant that hts_pack was a transparent transform that always gives back something even if it's actually just growing the data by 1 byte. However the CRAMcodecs spec states this scenario is illegal. The checks in rANS_static4x16pr.c were bugged for nsym==256 as there wasn't a check of "|| out[c_meta_len] == 0", but now it's a moot point as NULL will be returned. Fixes #65
Encoders that use
hts_pack
disable bit packing if there are more than 16 symbols, e.g., rANS Nx16 and the arithmetic range coder. However, the checks that disable bit packing compare against a potentially truncated value. When attempting to bit pack inputs with 256 symbols,out[c_meta_len]
is 0,out[c_meta_len] > 16
fails, and the encoders do not disable bit packing.An example using the rANS Nx16 test program (version 1.3.0):
The text was updated successfully, but these errors were encountered: