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

Conversation

@SimonSapin
Copy link
Contributor

SimonSapin commented Oct 6, 2019

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 #63291 (comment)
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Oct 6, 2019

r? @alexcrichton

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

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Oct 7, 2019

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

This comment has been minimized.

Copy link
Member

JohnCSimon commented Oct 12, 2019

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

@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Oct 16, 2019

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

@bors r=alexcrichton

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 16, 2019

📌 Commit 352b026 has been approved by alexcrichton

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Oct 16, 2019

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

This comment has been minimized.

Copy link
Member

RalfJung commented Oct 16, 2019

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

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

@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Oct 16, 2019

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

This comment has been minimized.

Copy link
Member

Centril commented Oct 16, 2019

Failed in #65482, @bors r-

@SimonSapin SimonSapin force-pushed the SimonSapin:zero-box branch from 352b026 to 227db40 Oct 18, 2019
@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Oct 18, 2019

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

@bors r=alexcrichton

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 18, 2019

📌 Commit 227db40 has been approved by alexcrichton

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 7 pull requests

Successful merges:

 - #65174 (Fix zero-size uninitialized boxes)
 - #65241 (build-std compatible sanitizer support)
 - #65302 (Upgrade GCC to 8.3.0, glibc to 1.17.0 and crosstool-ng to 1.24.0 for dist-armv7-linux)
 - #65469 (Update libc to 0.2.64)
 - #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)

Failed merges:

 - #65501 (Remove `src/llvm-emscripten` submodule)

r? @ghost
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
4 checks passed
4 checks passed
pr Build #20191018.70 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (LinuxTools) LinuxTools succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.