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 zero-size uninitialized boxes #65174

Merged
merged 3 commits into from
Oct 19, 2019
Merged

Fix zero-size uninitialized boxes #65174

merged 3 commits into from
Oct 19, 2019

Conversation

SimonSapin
Copy link
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
Collaborator

r? @alexcrichton

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 6, 2019
@alexcrichton
Copy link
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

@JohnCSimon JohnCSimon 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
Member

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

@SimonSapin
Copy link
Contributor Author

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

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented Oct 16, 2019

📌 Commit 352b026 has been approved by alexcrichton

@bors bors 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
Collaborator

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
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
Contributor Author

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)
@Centril
Copy link
Contributor

Centril commented Oct 16, 2019

Failed in #65482, @bors r-

@bors bors 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
Contributor Author

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

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented Oct 18, 2019

📌 Commit 227db40 has been approved by alexcrichton

@bors bors 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)
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)
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)
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:master Oct 19, 2019
@SimonSapin SimonSapin deleted the zero-box branch November 28, 2019 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: 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