lib: fix function pointers to please UndefinedBehaviorSanitizer - #15289
Merged
Conversation
jay
reviewed
Oct 14, 2024
bagder
marked this pull request as draft
October 14, 2024 08:30
bagder
force-pushed
the
bagder/cleaner-func-typecast
branch
from
October 14, 2024 10:41
75b31c5 to
dffb408
Compare
This comment was marked as outdated.
This comment was marked as outdated.
bagder
force-pushed
the
bagder/cleaner-func-typecast
branch
from
October 14, 2024 12:39
b979979 to
cedf3c1
Compare
bagder
force-pushed
the
bagder/cleaner-func-typecast
branch
from
October 15, 2024 09:57
b472bb1 to
fe9e69a
Compare
bagder
marked this pull request as ready for review
October 15, 2024 10:25
Make sure we use functions with the correct prototype. Closes #15289
It makes the callbacks get different signnatures when used from within libcurl vs outside of it by libcurl-using applications (such as the libtests) and this triggers UndefinedBehaviorSanitizer errors. Closes #15289
Make test applications use the correct prototypes for callbacks. Closes #15289
bagder
force-pushed
the
bagder/cleaner-func-typecast
branch
from
October 15, 2024 12:34
fe9e69a to
8403e5a
Compare
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
Make sure we use functions with the correct prototype. Closes curl#15289
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
It makes the callbacks get different signnatures when used from within libcurl vs outside of it by libcurl-using applications (such as the libtests) and this triggers UndefinedBehaviorSanitizer errors. Closes curl#15289
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
Make test applications use the correct prototypes for callbacks. Closes curl#15289
|
Aliasing everything to void has the downside of losing strict type checking. Also it breaks C++ code that defines CURL_STRICTER and contains references to these types. I think it is better to keep struct typedefs in CURL_STRICTER and build everything within curl source tree with it. This will make ubsan happy and API users may still use void aliases on platforms whose ABIs permit it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use plain typecasts instead to make it more obvious what the code does.
The UndefinedBehaviorSanitizer (ubsan) now errors if a callback pointer is used to a call a function with ever so slight difference in signature. This is annoying because it means that we can no longer use our long established practice of using a different typedef for several handles when building the library vs when using it. We used to have a plain struct pointer for libcurl builds and a
void *for that name when the header is used for applications.