fix (openjpeg): Change the malloc method to dlmalloc to fix memory issue#40
Merged
Conversation
…sue during decompression of some j2k images Changes the malloc method and adds tests for problematic (memory crashing) DX images
Contributor
Author
|
@wayfarer3130, @sedghi who would be a good person to review this? |
Member
|
CC @chafey |
wayfarer3130
approved these changes
Feb 6, 2024
Contributor
|
Chris - any chance you could take a look? @chafey |
|
A few comments:
|
Contributor
Author
Thank you @chafey, Happy to open an issue to report it. Would this repository be the correct place to open the issue? |
|
Yes I think so |
Contributor
Author
The problematic DX file fails only when it is in the beginning
|
@emelalkim issue looks good, thanks for that. Ill add some comments. BTW - impressive debugging work, this stuff is really complicated! |
Contributor
Author
Thank you @chafey. It was hard indeed! I must confess I needed to call reinforcements :) I got help from my brother @erdemalkim who is the actual c developer in the family |
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.
This change fixes the DX decompression problem that occurs in some j2k images with or without the latest changes in the openjpeg extern library and it has very minimal effect on the size of the distribution js files.
The current version of the codecs library cannot decompress some j2k DX images. See the issue for more information. Further investigation narrowed down the issue to malloc which is currently using emmalloc. While trying to allocate 595*4 bytes of memory with opj_aligned_malloc at this line in openjpeg library, it keeps increasing the size of the heap and crashes when it exceeds 2GB.
Changes:
Notes:
I ran all the commented-out tests to make sure it didn't mess up anything.
I also tested with my fork of openjpeg library (https://github.com/emelalkim/openjpeg) which is in sync with https://github.com/uclouvain/openjpeg.
The sizes of the js files are affected minimally

dist folder js sizes with emmalloc
dist folder js sizes with dlmalloc