8000 fixed a few remaining ubsan warnings in lz4hc by Cyan4973 · Pull Request #1160 · lz4/lz4 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fixed a few remaining ubsan warnings in lz4hc #1160

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

Merged
merged 1 commit into from
Sep 9, 2022
Merged

fixed a few remaining ubsan warnings in lz4hc #1160

merged 1 commit into from
Sep 9, 2022

Conversation

Cyan4973
Copy link
Member
@Cyan4973 Cyan4973 commented Sep 9, 2022

that were previously hidden due to the -fsanitize-recover=pointer-overflow flag.
The 2 minor instances involve pointer arithmetic with NULL ptr.

For the record, I also tried to fix a few remaining ubsan warnings in lz4.c,
related to pointer overflow arithmetic.
Unfortunately, the fix resulted in a massive drop in performance,
so it's not bundled here.

The issue (in lz4.c) is that the code uses a virtual pointer address base as a reference point for its indexing scheme.
The base pointer itself is never dereferenced, it's always combined with an index, in order to reference a valid address.
Nevertheless, from a ubsan perspective, it's an invalid operation.

Fixing that requires changing one variable (base) by 2 variables (prefixStart and prefixIndex) and an arithmetic operation (currentIndex - prefixIndex). It's a small difference (one more register, one more addition), but at the speed of lz4 fast mode, it's enough to make a sensible impact on performance.

Therefore, removing these last ubsan warnings will require finding a good replacement strategy, which doesn't involve a significant speed loss.

No such problem in lz4hc, which compression speed is much lower, and algorithm is more complex. Consequently, this issue has already been fixed (in previous release) without any noticeable drop in performance.

mostly related to pointer arithmetic involving NULL ptr.
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.

1 participant
0