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

Conversation

Projects
None yet
2 participants
@mtopolnik
Copy link

commented Jun 30, 2015

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.

@mtopolnik mtopolnik force-pushed the mtopolnik:wildcopy branch from 1f019e6 to c772948 Jun 30, 2015

Cyan4973 added a commit that referenced this pull request Jul 2, 2015

Merge pull request #134 from mtopolnik/wildcopy
Avoid out-of-bounds reading

@Cyan4973 Cyan4973 merged commit 9d8ed5c into lz4:wildcopy Jul 2, 2015

0 of 2 checks passed

continuous-integration/appveyor AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details

@mtopolnik mtopolnik deleted the mtopolnik:wildcopy branch Jul 2, 2015

@mtopolnik

This comment has been minimized.

Copy link
Author

commented Jul 4, 2015

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

commented Jul 6, 2015

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
You can’t perform that action at this time.