openframeworks / openframeworks/openFrameworks

ofColor undefined behavior

Open
#8,166 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

today I was analyzing code in XCode with address sanitizer on, undefined behavior sanitizer and it indicates an UB on ofColor

Screenshot 2024-10-31 at 00 03 17
ofColor.cpp:172:7: runtime error: 2.14748e+09 is outside the range of representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:172:7 in 
ofColor.cpp:173:7: runtime error: 2.14748e+09 is outside the range of representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:173:7 in 
ofColor.cpp:174:7: runtime error: 2.14748e+09 is outside the range of representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:174:7 in 
ofColor.cpp:175:7: runtime error: 2.14748e+09 is outside the range of representable values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:175:7 in 
ofColor.cpp:172:7: runtime error: 4.29497e+09 is outside the range of representable values of type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:172:7 in 
ofColor.cpp:173:7: runtime error: 4.29497e+09 is outside the range of representable values of type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:173:7 in 
ofColor.cpp:174:7: runtime error: 4.29497e+09 is outside the range of representable values of type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:174:7 in 
ofColor.cpp:175:7: runtime error: 4.29497e+09 is outside the range of representable values of type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:175:7 in 
ofColor.cpp:172:7: runtime error: 9.22337e+18 is outside the range of representable values of type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:172:7 in 
ofColor.cpp:173:7: runtime error: 9.22337e+18 is outside the range of representable values of type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:173:7 in 
ofColor.cpp:174:7: runtime error: 9.22337e+18 is outside the range of representable values of type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:174:7 in 
ofColor.cpp:175:7: runtime error: 9.22337e+18 is outside the range of representable values of type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:175:7 in 
ofColor.cpp:172:7: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:172:7 in 
ofColor.cpp:173:7: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:173:7 in 
ofColor.cpp:174:7: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:174:7 in 
ofColor.cpp:175:7: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ofColor.cpp:175:7 in 
setFbo 

and another one in ofGLProgrammableRenderer::draw

Screenshot 2024-10-31 at 00 05 59

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining ofColor.cpp around lines 172–175 and the setFbo path, then inspect the reported ofGLProgrammableRenderer::draw location. Reproduce the issue with XCode AddressSanitizer and UndefinedBehaviorSanitizer enabled, and determine the inputs that trigger the reported out-of-range conversions. Done means the sanitizer reports no undefined behavior in these paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.