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

CurlHandle: fix error message handling #522

Merged
merged 6 commits into from
Oct 29, 2024

Conversation

madsbk
Copy link
Member

@madsbk madsbk commented Oct 28, 2024

When building with conda, the __FILE__ macro will contain the (long) conda build path. At install time, this is replaced by the actual path, which may be shorter. Any extra characters are replaced by \0.

The extra \0 is problematic if CurlHandle later throws an exception to Cython since while converting the exception to Python, Cython might truncate the error message.

@madsbk madsbk added bug Something isn't working non-breaking Introduces a non-breaking change labels Oct 28, 2024
@madsbk madsbk marked this pull request as ready for review October 29, 2024 11:31
@madsbk madsbk requested a review from a team as a code owner October 29, 2024 11:31
@madsbk madsbk requested review from wence- and pentschev October 29, 2024 11:32
@wence-
Copy link
Contributor

wence- commented Oct 29, 2024

Can you add a description of what you observed is the problematic thing this is fixing please?

cpp/include/kvikio/shim/libcurl.hpp Outdated Show resolved Hide resolved
* `std::string` from a `char*`, the compiler might optimize the code such that the `std::string`
* is created from the full size of `__FILE__` including the trailing `\0` chars.
*/
__attribute__((optnone)) inline std::string fix_conda_file_path_hack(std::string filename)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: I think we should explicitly request noinline rather than hoping that optnone will ensure the function is not inlined.

Suggested change
__attribute__((optnone)) inline std::string fix_conda_file_path_hack(std::string filename)
__attribute__((noinline)) inline std::string fix_conda_file_path_hack(std::string filename)

Copy link
Member

@pentschev pentschev Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do both, no?

__attribute__((optnone)) __attribute__((noinline)) std::string fix_conda_file_path_hack(std::string filename)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't see optnone as a valid attribute in the GCC documentation: https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Common-Function-Attributes.html

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, somehow it's not in GCC's but it's in Clang's saying it's available in GNU (I assume GCC): https://clang.llvm.org/docs/AttributeReference.html#optnone

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should be __attribute__((optimize(0))) instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should be __attribute__((optimize(0))) instead?

Does clang support optimize(0) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optimize is undocumented in Clang. 🤣

I guess you'll either have to risk leaving optnone or do some compiler checking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, lovely :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see if __attribute__((noinline)) is enough

@madsbk madsbk requested a review from wence- October 29, 2024 12:32
Copy link
Member

@pentschev pentschev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a68b9aa works then this is probably good as is. However, as @wence- pointed out optnone is not documented in GCC and perhaps might require something different such as optimize(0).

@madsbk
Copy link
Member Author

madsbk commented Oct 29, 2024

/merge

@rapids-bot rapids-bot bot merged commit f9e3466 into rapidsai:branch-24.12 Oct 29, 2024
57 checks passed
@madsbk
Copy link
Member Author

madsbk commented Oct 29, 2024

@wence- @pentschev, thanks for the help debugging this!

@madsbk madsbk deleted the trim__FILE__ branch October 29, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working non-breaking Introduces a non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants