Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Strict aliasing violation in scan_with_buffer #815

Closed
jlebar opened this issue Jul 8, 2016 · 6 comments
Closed

Strict aliasing violation in scan_with_buffer #815

jlebar opened this issue Jul 8, 2016 · 6 comments
Assignees
Labels
type: bug: functional Does not work as intended. unverified Cannot be reproduced or confirmed.

Comments

@jlebar
Copy link

jlebar commented Jul 8, 2016

https://github.com/thrust/thrust/blob/25669cd425a8f4d896e4a631683899e55086f733/thrust/system/cuda/detail/bulk/algorithm/scan.hpp#L357

If input_type and intermediate_type are not the same, a C++ compiler can assume that a pointer of type input_type* does not alias a pointer of type intermediate_type*. Yet here they clearly do alias when we invoke scan() below.

This can lead to all sorts of difficult-to-track-down bugs.

@brycelelbach
Copy link
Collaborator

We've switched to a new implementation for the CUDA backend. Amusingly, there is another union problem in the new backend, but I'm pretty sure this is no longer an issue. Leaving it open until I can confirm. Also, hi Justin.

@brycelelbach brycelelbach self-assigned this Sep 15, 2017
@brycelelbach brycelelbach added type: bug: functional Does not work as intended. unverified Cannot be reproduced or confirmed. labels Sep 15, 2017
@jlebar
Copy link
Author

jlebar commented Sep 15, 2017

Hi, Bryce. :)

We've switched to a new implementation for the CUDA backend.

Hm, I'm not sure what you mean.

I was referring to the fact that this code can miscompile if you compile with clang.

@brycelelbach
Copy link
Collaborator

Sorry: what I meant is that this is likely no longer an issue, because the code in question has been rewritten in the CUDA toolkit version of Thrust.

@andrewcorrigan
Copy link
Contributor

Is the CUDA toolkit version of Thrust open-source? Are you going to merge the github repository with the CUDA toolkit version?

@brycelelbach
Copy link
Collaborator

Yes, the version of CUDA that ships with Thrust is open source.

I don't have an answer for the second question right now.

@brycelelbach
Copy link
Collaborator

Closing; this is no longer an issue, although there are other places where unions may be abused.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug: functional Does not work as intended. unverified Cannot be reproduced or confirmed.
Projects
None yet
Development

No branches or pull requests

3 participants