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

Avoid out-of-bounds reading #134

Merged
merged 1 commit into from Jul 2, 2015
Merged

Avoid out-of-bounds reading #134

merged 1 commit into from Jul 2, 2015

Conversation

mtopolnik
Copy link

Reworked reading from before the malloc'd buffer into within-bound reading followed by a left shift (little-endian logic applies here).

Unfortunately, the performance of MT_wildCopyNarrowLE is halved when unaligned pointer ops are replaced with memcpy. More work should be applied to avoid memcpy.

Cyan4973 added a commit that referenced this pull request Jul 2, 2015
Avoid out-of-bounds reading
@Cyan4973 Cyan4973 merged commit 9d8ed5c into lz4:wildcopy Jul 2, 2015
@mtopolnik mtopolnik deleted the wildcopy branch July 2, 2015 07:38
@mtopolnik
Copy link
Author

I have completed the implementation of MT_wildCopyNarrowLE which uses aligned writing, but it didn't solve the performance issue. However, I also found out that the issue is specific to clang (on my local system) whereas gcc does rather well with the current code.

The code is committed here should there be any future need to evaluate it.

@Cyan4973
Copy link
Member

Cyan4973 commented Jul 6, 2015

I guess there will be a need to work on branching predictibility to make this solution fly under "normal" conditions too.

@mtopolnik
Copy link
Author

One possile idea to try out is using | instead of || in the first if condition. Theoretically the compiler should already know what is best for performance, but there still may be a chance for improvement.

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.

None yet

2 participants