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

UBSan issue when loading an .exr #187

Open
jdumas opened this issue Jan 12, 2023 · 2 comments
Open

UBSan issue when loading an .exr #187

jdumas opened this issue Jan 12, 2023 · 2 comments

Comments

@jdumas
Copy link

jdumas commented Jan 12, 2023

Describe the issue
Loading a certain .exr image with UBSan enabled flags some issues in tinyexr.

To Reproduce
Steps to reproduce the behavior:

  1. Compile TinyEXR with UBSan (-fsanitize=undefined)
  2. Load EXR Image with LoadEXRImageFromFile
  3. See error
tinyexr/tinyexr.h:1999:12: runtime error: left shift of 585757245565577410 by 8 places cannot be represented in type 'long long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tinyexr/tinyexr.h:1999:12 in
tinyexr/tinyexr.h:2659:5: runtime error: left shift of 769045763242690055 by 8 places cannot be represented in type 'long long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tinyexr/tinyexr.h:2659:5 in
tinyexr/tinyexr.h:2735:33: runtime error: left shift of 115287495861464541 by 8 places cannot be represented in type 'long long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tinyexr/tinyexr.h:2735:33 in

Image: plastic_stripes_Height.exr.zip

Expected behavior
I am not sure whether it's an issue with our .exr image, or a problem in tinyexr, but I'd expect tinyexr to not trigger any runtime UBSan error (this one seems like a shift integer overflow?).

Environment

  • OS: macOS
  • Compiler: AppleClang 14.0.0.14000029
  • Tinyexr version: latest (02310c7)
@syoyo
Copy link
Owner

syoyo commented Jan 12, 2023

These UBSan reported line of codes points to codes ported from OpenEXR(not written by me) and somewhat difficult to understand such codes. The reason would be integer overflows. But I'm not sure simple overflow fix is sufficient. It may introduce some side-effects.

Proper solution would be replace OpenEXR-derived codes with our own #186

For a while, we can simply ignore/suppress UBSan warning: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#disabling-instrumentation-with-attribute-no-sanitize-undefined

@jdumas
Copy link
Author

jdumas commented Jan 12, 2023

Ah the wuffs thing sounds nice. Guess I'll just ignore these issues for now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants