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

unsafe_wrap with incorrect bounds is UB #36

Open
vtjnash opened this issue Oct 23, 2023 · 0 comments
Open

unsafe_wrap with incorrect bounds is UB #36

vtjnash opened this issue Oct 23, 2023 · 0 comments

Comments

@vtjnash
Copy link
Member

vtjnash commented Oct 23, 2023

LLVM could theoretically detect that this array iteration bound is invalid, and generate illegal loads here, since the information passed to unsafe_wrap is not valid (the max possible legal size here is also typemax(Int)/sizeof(Int), though that still would trigger UB)

function listallplots(nplots=Int(maxintfloat()))
. Using maxintfloat is even more of an issue here because (a) Float is not involved anywhere (b) On 32-bit, that would correspond to exactly typemax, but that is not larger than the representable maximum value that is legal.

It is not particularly clear why it would decide to try to vectorize this code, since unsafe_string is already expensive there, but formally this array size could trigger UB since it aliases other memory and points to memory that is undefined.

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

No branches or pull requests

1 participant