Skip to content

Fix truncated drop pattern on 32bit -> 64bit cross compilation #31283

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

Merged
merged 1 commit into from
Jan 29, 2016

Conversation

dotdash
Copy link
Contributor

@dotdash dotdash commented Jan 29, 2016

When cross compiling for a target that has a larger usize type than the
host system, we use a truncated value to mark data as dropped,
eventually leading to drop calls on already dropped data. To properly
handle this, the drop pattern needs to be of type u64.

Since C_integral truncates its given value to the requested size anyway,
we can also drop the function that chose between the u32 and u64 values,
and always use the u64 constant.

Fixes #31139

r? @pnkfelix

When cross compiling for a target that has a larger usize type than the
host system, we use a truncated value to mark data as dropped,
eventually leading to drop calls on already dropped data. To properly
handle this, the drop pattern needs to be of type u64.

Since C_integral truncates its given value to the requested size anyway,
we can also drop the function that chose between the u32 and u64 values,
and always use the u64 constant.

Fixes rust-lang#31139
@alexcrichton
Copy link
Member

Thanks @dotdash! I was wondering of ways we might test this but I couldn't think of one (short of inspecting IR), so r+ from me at least

@dotdash
Copy link
Contributor Author

dotdash commented Jan 29, 2016

@bors r=alexcrichton

I've talked to @pnkfelix on IRC about this and he didn't know of a way to test this either and also said that he's fine with this approach of using the constant directly, so I'll take you r+ :-)

@bors
Copy link
Collaborator

bors commented Jan 29, 2016

📌 Commit fdf65e7 has been approved by alexcrichton

@bors
Copy link
Collaborator

bors commented Jan 29, 2016

⌛ Testing commit fdf65e7 with merge 074f49a...

bors added a commit that referenced this pull request Jan 29, 2016
When cross compiling for a target that has a larger usize type than the
host system, we use a truncated value to mark data as dropped,
eventually leading to drop calls on already dropped data. To properly
handle this, the drop pattern needs to be of type u64.

Since C_integral truncates its given value to the requested size anyway,
we can also drop the function that chose between the u32 and u64 values,
and always use the u64 constant.

Fixes #31139

r? @pnkfelix
1 similar comment
@bors bors merged commit fdf65e7 into rust-lang:master Jan 29, 2016
@dotdash dotdash deleted the 32_64_cc branch January 31, 2016 15:28
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

Successfully merging this pull request may close these issues.

4 participants