Skip to content

Fix zero-size uninitialized boxes - #65174

Merged
bors merged 3 commits into
rust-lang:masterfrom
SimonSapin:zero-box
Oct 19, 2019
Merged

Fix zero-size uninitialized boxes#65174
bors merged 3 commits into
rust-lang:masterfrom
SimonSapin:zero-box

Conversation

@SimonSapin

Copy link
Copy Markdown
Contributor

Requesting a zero-size allocation is not allowed, return a dangling pointer instead.

CC #63291 (comment)

Requesting a zero-size allocation is not allowed,
return a dangling pointer instead.
CC rust-lang#63291 (comment)
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @alexcrichton

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

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 6, 2019
@alexcrichton

Copy link
Copy Markdown
Member

Looks good to me, thanks! Could this perhaps though check the alloc.size() calculation instead of recalculating the size of T and factoring in the length? Other than that though r=me with some tests

@JohnCSimonJohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 12, 2019
@JohnCSimon

Copy link
Copy Markdown

Ping from triage
@SimonSapin can you address @alexcrichton 's requests?
Thanks

@SimonSapin

Copy link
Copy Markdown
ContributorAuthor

Done. I’ll take the liberty to carry Alex’s “r=me” from previous comment:

@bors r=alexcrichton

@bors

bors commented Oct 16, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 352b026 has been approved by alexcrichton

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 16, 2019
@rust-highfive

Copy link
Copy Markdown
Contributor

The job x86_64-gnu-llvm-6.0 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-10-16T18:34:54.3912255Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-10-16T18:34:54.4098898Z ##[command]git config gc.auto 0
2019-10-16T18:34:54.4185459Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-10-16T18:34:54.4250759Z ##[command]git config --get-all http.proxy
2019-10-16T18:34:55.0155008Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/65174/merge:refs/remotes/pull/65174/merge
---
2019-10-16T18:42:14.4937529Z Compiling serde_json v1.0.40
2019-10-16T18:42:16.4223505Z Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
2019-10-16T18:42:28.6972252Z Finished release [optimized] target(s) in 1m 36s
2019-10-16T18:42:28.7052623Z tidy check
2019-10-16T18:42:28.8372721Z tidy error: /checkout/src/liballoc/tests/boxed.rs: too many trailing newlines (2)
2019-10-16T18:42:30.8079203Z some tidy checks failed
2019-10-16T18:42:30.8079301Z Found 482 error codes
2019-10-16T18:42:30.8079355Z Found 0 error codes with no tests
2019-10-16T18:42:30.8079607Z Done!
2019-10-16T18:42:30.8079607Z Done!
2019-10-16T18:42:30.8079638Z 2019-10-16T18:42:30.8079667Z 2019-10-16T18:42:30.8080535Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor"
2019-10-16T18:42:30.8080673Z 2019-10-16T18:42:30.8080700Z 2019-10-16T18:42:30.8086476Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2019-10-16T18:42:30.8087326Z Build completed unsuccessfully in 0:01:39
2019-10-16T18:42:30.8087326Z Build completed unsuccessfully in 0:01:39
2019-10-16T18:42:30.8137988Z == clock drift check ==
2019-10-16T18:42:30.8160231Z local time: Wed Oct 16 18:42:30 UTC 2019
2019-10-16T18:42:30.9049248Z network time: Wed, 16 Oct 2019 18:42:30 GMT
2019-10-16T18:42:30.9052471Z == end clock drift check ==
2019-10-16T18:42:32.2598861Z ##[error]Bash exited with code '1'.
2019-10-16T18:42:32.2633494Z ##[section]Starting: Checkout
2019-10-16T18:42:32.2635221Z ==============================================================================
2019-10-16T18:42:32.2635296Z Task : Get sources
2019-10-16T18:42:32.2635347Z Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@RalfJung

Copy link
Copy Markdown
Member

Dang, I missed that when reviewing the original patch. :/

Do the Rc/Arc uninit constructors by any chance have similar issues?

@SimonSapin

Copy link
Copy Markdown
ContributorAuthor

Heap allocations for Rc or Arc are never zero-size since they contain at least the refcounts

Centril added a commit to Centril/rust that referenced this pull request Oct 16, 2019
Fix zero-size uninitialized boxes
Requesting a zero-size allocation is not allowed, return a dangling pointer instead.
CC rust-lang#63291 (comment)
@CentrilCentril mentioned this pull request Oct 16, 2019
@Centril

Copy link
Copy Markdown
Contributor

Failed in #65482, @bors r-

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 16, 2019
@SimonSapin

Copy link
Copy Markdown
ContributorAuthor

Removed the extra trailing newline, and ran a full ./x.py test

@bors r=alexcrichton

@bors

bors commented Oct 18, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 227db40 has been approved by alexcrichton

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 18, 2019
Centril added a commit to Centril/rust that referenced this pull request Oct 19, 2019
Fix zero-size uninitialized boxes
Requesting a zero-size allocation is not allowed, return a dangling pointer instead.
CC rust-lang#63291 (comment)
@CentrilCentril mentioned this pull request Oct 19, 2019
Centril added a commit to Centril/rust that referenced this pull request Oct 19, 2019
Fix zero-size uninitialized boxes
Requesting a zero-size allocation is not allowed, return a dangling pointer instead.
CC rust-lang#63291 (comment)
@CentrilCentril mentioned this pull request Oct 19, 2019
Centril added a commit to Centril/rust that referenced this pull request Oct 19, 2019
Fix zero-size uninitialized boxes
Requesting a zero-size allocation is not allowed, return a dangling pointer instead.
CC rust-lang#63291 (comment)
@CentrilCentril mentioned this pull request Oct 19, 2019
bors added a commit that referenced this pull request Oct 19, 2019
Rollup of 6 pull requests
Successful merges:
- #65174 (Fix zero-size uninitialized boxes)
- #65252 (expand: Simplify expansion of derives)
- #65485 (Suppress ICE when validators disagree on `LiveDrop`s in presence of `&mut`)
- #65542 (Refer to "associated functions" instead of "static methods")
- #65545 (More symbol cleanups)
- #65576 (Don't add `argc` and `argv` arguments to `main` on WASI.)
Failed merges:
r? @ghost
@bors
bors merged commit 227db40 into rust-lang:masterOct 19, 2019
@SimonSapin
SimonSapin deleted the zero-box branch November 28, 2019 12:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@SimonSapin@rust-highfive@alexcrichton@JohnCSimon@bors@RalfJung@Centril