Skip to content

Fix unaligned loads in librustc_metadata - #38352

Merged
bors merged 1 commit into
rust-lang:masterfrom
bluss:unaligned-metadata
Dec 16, 2016
Merged

Fix unaligned loads in librustc_metadata#38352
bors merged 1 commit into
rust-lang:masterfrom
bluss:unaligned-metadata

Conversation

@bluss

@blussbluss commented Dec 13, 2016

Copy link
Copy Markdown
Contributor

Creating a &[u32] from an &[u8] is not necessarily valid, and crashes
on certain platforms if the data is not well aligned.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

Comment threadsrc/librustc_metadata/index.rs Outdated

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

cc @eddyb this was introduced in #36551

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

hm.. no, sorry! It is from before that.

@bluss

Copy link
Copy Markdown
ContributorAuthor

This was reported as a crash on sparc64.

Comment threadsrc/librustc_metadata/index.rs Outdated

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Maybe we should lint against this? Creating a slice or reference from a less aligned pointer?

Creating a `&[u32]` from a `&[u8]` was not valid; the data is not
necessarily well aligned.
@bluss

Copy link
Copy Markdown
ContributorAuthor

Hey presto, the diff is much shorter with a bit of help from @eddyb.

@eddyb

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Dec 14, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit 7bc1054 has been approved by eddyb

@bors

bors commented Dec 16, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 7bc1054 with merge 8ae9040...

bors added a commit that referenced this pull request Dec 16, 2016
Fix unaligned loads in librustc_metadata
Creating a `&[u32]` from an `&[u8]` is not necessarily valid, and crashes
on certain platforms if the data is not well aligned.
@bors
bors merged commit 7bc1054 into rust-lang:masterDec 16, 2016
@bluss
bluss deleted the unaligned-metadata branch December 16, 2016 19:23
Sign up for freeto 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.

5 participants

@bluss@rust-highfive@eddyb@bors@pnkfelix