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

Fix corrupted Vec creation in util::read_spir_v_file #21

Closed
wants to merge 5 commits into from

Conversation

acgaudette
Copy link
Contributor

I was debugging some strange memory problems and noticed that jemalloc would regularly freak out when Rust drops the buffer containing my shader bytecode. I traced it to this method.

Using Vec::from_raw_parts unfortunately can corrupt the data on the heap unless the new and old types share the same size and alignment.

https://doc.rust-lang.org/std/vec/struct.Vec.html#method.from_raw_parts

Instead, I used slice::from_raw_parts and to_vec() which is an in-place call (no copies) and should not incur an additional performance hit. The buffers are now dropped safely on my end.

Possibly related to #20--my issue has disappeared since this fix.

@acgaudette
Copy link
Contributor Author

Note: after further testing, I determined this is unrelated to #20.

@acgaudette
Copy link
Contributor Author

Replaced with #22

@acgaudette acgaudette closed this Oct 28, 2018
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.

1 participant