Skip to content
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

Fix compression of data blocks close to 2GB in size. #55

Merged
merged 2 commits into from
Jul 14, 2022

Conversation

jkbonfield
Copy link
Collaborator

(We still have a limit of >2GB though)

Reported by Divon Lan

@@ -93,7 +93,7 @@ static unsigned char *load(FILE *infp, uint32_t *lenp) {
*/
int main(int argc, char **argv) {
int opt, order = 0;
unsigned char in_buf[BLK_SIZE2+257*257*3];
unsigned char *in_buf = malloc(BLK_SIZE2+257*257*3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address sanitizer complains that this gets leaked.

The similar changes to malloc'd blocks in the other tests seem to get a pass as the buffers being replaced are currently global.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true, but I didn't think it'd matter given it's essentially the same as a huge static array (it's freed on program exit). I forgot about automated tests highlighting it though. I'll fix as it's useful to be able to use the test tools complaint-free to look for problems elsewhere.

I did also think about checking for NULL, but frankly if it can't fit then it wouldn't have fitted before and both would just die. Not a problem given this isn't a production tool, unless a compiler is going to start asserting error checking.

(We still have a limit of >2GB though)

Reported by Divon Lan
@daviesrob
Copy link
Member

The fixes look OK. I think it would be a good idea to add explicit checks on the 2 Gbyte limit though. At the moment it's not obvious if there is a limit, and it looks like there will be problems if you try to go over that.

Also limit input buffer sizes to 2GB.
@jkbonfield
Copy link
Collaborator Author

I added checks for the 2GB limit so it just returns a hard NULL early on.

@daviesrob daviesrob merged commit 0523328 into samtools:master Jul 14, 2022
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.

2 participants