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

Use NonNull in the allocator API #49608

Closed
wants to merge 1 commit into from
Closed

Conversation

glandium
Copy link
Contributor

@glandium glandium commented Apr 3, 2018

As discussed in #32838 (comment)
and following, instead of *mut pointers, use NonNull for the allocator
API.

One issue is that older rustc versions, used to bootstrap the compiler,
expands #[global_allocator], used in various places including libstd or
librustc_[almt]san, to code that uses the Alloc trait, so changes to
that trait make bootstrapping fail. Thankfully, it does so through the
location of the Alloc trait before 94d1970
so we can use at our advantage by making stage0 expose the old API as
alloc::heap::Alloc.

At the same time, we change the expansion for #[global_allocator] to use
the new trait location under core, which will allow newer versions of
rustc to bootstrap stage0 as well, despite the workaround described above.

The downside is that this is a breaking change, albeit, for an unstable feature,
that will pile up with the upcoming GlobalAlloc change. It /might/ make sense to
wait for GlobalAlloc to go in first, so that #[global_allocator] only breaks once.
But I still wanted to put this out there, get feedback on the change itself. It will be
trivial to rebase on top of GlobalAlloc if we decide to wait for that.

Cc @SimonSapin @alexcrichton

@TimNN
Copy link
Contributor

TimNN commented Apr 3, 2018

Your PR failed on Travis. 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.
[00:01:03] configure: rust.quiet-tests     := True
---
[00:06:37] tidy error: /checkout/src/liballoc/heap.rs:153: line longer than 100 chars
[00:06:37] tidy error: /checkout/src/liballoc/heap.rs:170: line longer than 100 chars
[00:06:37] tidy error: /checkout/src/libcore/heap.rs:695: line longer than 100 chars
[00:06:38] tidy error: /checkout/src/liballoc_system/lib.rs:174: line longer than 100 chars
[00:06:39] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:06:39] Build completed unsuccessfully in 0:02:47
[00:06:39] Makefile:79: recipe for target 'tidy' failed
[00:06:39] make: *** [tidy] Error 1
---
$ cat obj/tmp/sccache.log
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:18010320:start=1522714655637117729,finish=1522714655647136197,duration=10018468
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:2669a276
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:2669a276:start=1522714655655879169,finish=1522714655664367478,duration=8488309
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:21033209
$ dmesg | grep -i kill
[   11.445656] init: failsafe main process (1094) killed by TERM signal

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.

@TimNN
Copy link
Contributor

TimNN commented Apr 3, 2018

Your PR failed on Travis. 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.
[00:00:57] configure: rust.quiet-tests     := True
---
[00:41:03] .........................................................................i..........................
[00:41:09] ................i...................................................................................
---
[00:41:44] ............................................................................................i.......
[00:41:51] ................................................................i...................................
---
[00:42:29] ........FF.F........................................................................................
[00:42:46] .............................................i......................................................
---
[00:46:46] .............................i......................................................................
[00:47:01] ...............................................................i....................................
[00:47:16] ...............................................i....................................................
[00:47:37] ....................................................................................................
[00:47:58] ....................................................................................................
[00:48:20] ....................................................................................................
[00:48:46] .i................................................................................................i.
[00:49:12] .................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:49:22] ...................
[00:49:52] ....................................................F...............................................
[00:50:28] ...........F...................................................ii...................................
[00:51:14] ..........................i....................................................i.ii....test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:51:19] .............
[00:52:00] .......................................................................................iiiiiii......
---
[00:53:38] error: auxiliary build of "/checkout/src/test/run-pass/allocator/auxiliary/custom.rs" failed to compile:
[00:53:38] status: exit code: 101
[00:53:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/allocator/auxiliary/custom.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--target=x86_64-unknown-linux-gnu" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/allocator/xcrate-use.stage2-x86_64-unknown-linux-gnu.aux" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/allocator/xcrate-use.stage2-x86_64-unknown-linux-gnu.aux"
---
[00:53:38] error[E0053]: method `alloc` has an incompatible type for trait
[00:53:38]   --> /checkout/src/test/run-pass/allocator/auxiliary/custom.rs:22:5
[00:53:38]    |
[00:53:38] 22 |     unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
[00:53:38]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::ptr::NonNull`, found *-ptr
[00:53:38]    |
[00:53:38]    = note: expected type `unsafe fn(&mut &'a A, std::heap::Layout) -> std::result::Result<std::ptr::NonNull<u8>, std::heap::AllocErr>`
[00:53:38]               found type `unsafe fn(&mut &'a A, std::heap::Layout) -> std::result::Result<*mut u8, std::heap::AllocErr>`
[00:53:38]
[00:53:38] error[E0053]: method `dealloc` has an incompatible type for trait
[00:53:38]   --> /checkout/src/test/run-pass/allocator/auxiliary/custom.rs:27:5
[00:53:38]    |
[00:53:38] 27 |     unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) {
[00:53:38]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::ptr::NonNull`, found *-ptr
[00:53:38]    |
[00:53:38]    = note: expected type `unsafe fn(&mut &'a A, std::ptr::NonNull<u8>, std::heap::Layout)`
[00:53:38]               found type `unsafe fn(&mut &'a A, *mut u8, std::heap::Layout)`
---
[00:53:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/allocator/custom.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--target=x86_64-unknown-linux-gnu" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/allocator/custom.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/allocator/custom.stage2-x86_64-unknown-linux-gnu.aux"
---
[00:53:38] error[E0053]: method `alloc` has an incompatible type for trait
[00:53:38]   --> /checkout/src/test/run-pass/allocator/custom.rs:26:5
[00:53:38]    |
[00:53:38] 26 |     unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
[00:53:38]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::ptr::NonNull`, found *-ptr
[00:53:38]    |
[00:53:38]    = note: expected type `unsafe fn(&mut &'a A, std::heap::Layout) -> std::result::Result<std::ptr::NonNull<u8>, std::heap::AllocErr>`
[00:53:38]               found type `unsafe fn(&mut &'a A, std::heap::Layout) -> std::result::Result<*mut u8, std::heap::AllocErr>`
[00:53:38]
[00:53:38] error[E0053]: method `dealloc` has an incompatible type for trait
[00:53:38]   --> /checkout/src/test/run-pass/allocator/custom.rs:31:5
[00:53:38]    |
[00:53:38] 31 |     unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) {
[00:53:38]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::ptr::NonNull`, found *-ptr
[00:53:38]    |
[00:53:38]    = note: expected type `unsafe fn(&mut &'a A, std::ptr::NonNull<u8>, std::heap::Layout)`
[00:53:38]               found type `unsafe fn(&mut &'a A, *mut u8, std::heap::Layout)`
---
[00:53:38] thread '[run-pass] run-pass/allocator/custom.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:2901:9
[00:53:38]
[00:53:38] ---- [run-pass] run-pass/allocator/xcrate-use2.rs stdout ----
[00:53:38]
[00:53:38] error: auxiliary build of "/checkout/src/test/run-pass/allocator/auxiliary/custom.rs" failed to compile:
[00:53:38] status: exit code: 101
[00:53:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/allocator/auxiliary/custom.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--target=x86_64-unknown-linux-gnu" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/allocator/xcrate-use2.stage2-x86_64-unknown-linux-gnu.aux" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/allocator/xcrate-use2.stage2-x86_64-unknown-linux-gnu.aux"
---
[00:53:38] error[E0053]: method `alloc` has an incompatible type for trait
[00:53:38]   --> /checkout/src/test/run-pass/allocator/auxiliary/custom.rs:22:5
[00:53:38]    |
[00:53:38] 22 |     unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
[00:53:38]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::ptr::NonNull`, found *-ptr
[00:53:38]    |
[00:53:38]    = note: expected type `unsafe fn(&mut &'a A, std::heap::Layout) -> std::result::Result<std::ptr::NonNull<u8>, std::heap::AllocErr>`
[00:53:38]               found type `unsafe fn(&mut &'a A, std::heap::Layout) -> std::result::Result<*mut u8, std::heap::AllocErr>`
[00:53:38]
[00:53:38] error[E0053]: method `dealloc` has an incompatible type for trait
[00:53:38]   --> /checkout/src/test/run-pass/allocator/auxiliary/custom.rs:27:5
[00:53:38]    |
[00:53:38] 27 |     unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) {
[00:53:38]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::ptr::NonNull`, found *-ptr
[00:53:38]    |
[00:53:38]    = note: expected type `unsafe fn(&mut &'a A, std::ptr::NonNull<u8>, std::heap::Layout)`
[00:53:38]               found type `unsafe fn(&mut &'a A, *mut u8, std::heap::Layout)`
---
[00:53:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/realloc-16687.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--target=x86_64-unknown-linux-gnu" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/realloc-16687.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/realloc-16687.stage2-x86_64-unknown-linux-gnu.aux"
---
[00:53:38] 48 |     unsafe fn allocate(layout: Layout) -> *mut u8 {
[00:53:38]    |                                           ------- expected `*mut u8` because of return type
[00:53:38] ...
[00:53:38] 59 |         ret
[00:53:38]    |         ^^^ expected *-ptr, found struct `std::ptr::NonNull`
[00:53:38]    |
[00:53:38]    = note: expected type `*mut u8`
[00:53:38]               found type `std::ptr::NonNull<u8>`
[00:53:38]
[00:53:38] error[E0308]: mismatched types
[00:53:38]   --> /checkout/src/test/run-pass/realloc-16687.rs:67:22
[00:53:38]    |
[00:53:38] 67 |         Heap.dealloc(ptr, layout);
[00:53:38]    |                      ^^^ expected struct `std::ptr::NonNull`, found *-ptr
[00:53:38]    |
[00:53:38]    = note: expected type `std::ptr::NonNull<u8>`
[00:53:38]               found type `*mut u8`
[00:53:38]
[00:53:38] error[E0308]: mismatched types
[00:53:38]   --> /checkout/src/test/run-pass/realloc-16687.rs:75:32
[00:53:38]    |
[00:53:38] 75 |         let ret = Heap.realloc(ptr, old.clone(), new.clone())
[00:53:38]    |                                ^^^ expected struct `std::ptr::NonNull`, found *-ptr
[00:53:38]    |
[00:53:38]    = note: expected type `std::ptr::NonNull<u8>`
[00:53:38]               found type `*mut u8`
[00:53:38]
[00:53:38] error[E0308]: mismatched types
[00:53:38]   --> /checkout/src/test/run-pass/realloc-16687.rs:82:9
[00:53:38]    |
[00:53:38] 70 |     unsafe fn reallocate(ptr: *mut u8, old: Layout, new: Layout) -> *mut u8 {
[00:53:38]    |                                                                     ------- expected `*mut u8` because of return type
[00:53:38] ...
[00:53:38] 82 |         ret
[00:53:38]    |         ^^^ expected *-ptr, found struct `std::ptr::NonNull`
[00:53:38]    |
[00:53:38]    = note: expected type `*mut u8`
[00:53:38]               found type `std::ptr::NonNull<u8>`
---
[00:53:38] thread '[run-pass] run-pass/realloc-16687.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:2901:9
[00:53:38]
[00:53:38] ---- [run-pass] run-pass/regions-mock-trans.rs stdout ----
[00:53:38]
[00:53:38] error: compilation failed!
[00:53:38] status: exit code: 101
[00:53:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/regions-mock-trans.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--target=x86_64-unknown-linux-gnu" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/regions-mock-trans.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/regions-mock-trans.stage2-x86_64-unknown-linux-gnu.aux"
[00:5android-cross-path" "" "--color" "always"
[00:53:38] expected success, got: exit code: 101
[00:53:38]
[00:53:38]
[00:53:38] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:53:38] Build completed unsuccessfully in 0:13:21
[00:53:38] make: *** [check] Error 1
[00:53:38] Makefile:58: recipe for target 'check' failed
---
56708 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/incremental/syntax-33oa6nnkk1g08
56704 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/incremental/syntax-33oa6nnkk1g08/s-ezrcnlytcg-801bkp-c5w3u8gtr0ww
---
34544 ./obj/build/x86_64-unknown-linux-gnu/stage1-russtart:08d98f40
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:08d98f40:start=1522722454529367810,finish=1522722454536399606,duration=7031796
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:23154f42
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:23154f42:start=1522722454542682585,finish=1522722454549008861,duration=6326276
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:03eb59e4
$ dmesg | grep -i kill
[   10.980154] init: failsafe main process (1095) killed by TERM signal

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.

@TimNN
Copy link
Contributor

TimNN commented Apr 3, 2018

Your PR failed on Travis. 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.
[00:00:55] configure: rust.quiet-tests     := True
---
[00:42:29] .........................................................................i..........................
[00:42:35] ................i...................................................................................
---
[00:43:11] ............................................................................................i.......
[00:43:18] .................................................................i..................................
---
[00:44:14] .............................................i......................................................
---
[00:48:13] .............................i......................................................................
[00:48:28] ..............................................................i.....................................
[00:48:44] ...............................................i....................................................
[00:49:05] ....................................................................................................
[00:49:27] ....................................................................................................
[00:49:49] ....................................................................................................
[00:50:14] .i................................................................................................i.
[00:50:41] ...............................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:50:52] .....................
[00:51:24] ....................................................................................................
[00:52:01] ...............................................................ii...................................
[00:52:46] ..........................i....................................................i.ii.test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:52:53] ................
[00:53:34] .......................................................................................iiiiiii......
---
[00:55:34] ....................................i...............................................................
[00:55:42] ....................................................................................................
[00:55:50] ..................i............................................................ii.iii...............
[00:55:57] ....................................................................................................
[00:56:05] ........i..............................i............................................................
[00:56:13] ....................................................................................................
[00:56:20] .....................i..............................................................................
[00:56:28] ....................................................................................................
[00:56:38] ....................................................................................................
[00:56:49] ....................................................................................................
[00:57:00] ....................................................................................................
[00:57:14] ....................................................................................................
[00:57:24] ..............i.....................................................................................
[00:57:34] .................i..ii..............................................................................
[00:57:44] ....................................................................................................
[00:57:54] ....................................................................................................
[00:58:04] ....................................................................................i...............
[00:58:15] ..............................i.....................................................................
---
[00:58:53] ...........................i........................................................................
[00:58:55] ....................................................................i...............................
[00:58:56] ................i.......................................................
---
[00:59:12] ...........i........................
---
[00:59:42] i...i..ii....i.............ii........iii......i..i...i...ii..i..i..ii.....
---
[00:59:45] i.......i......................i......
---
[01:00:24] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[01:00:25] ....ii...
---
[01:09:59] ...i................................................................................................
---
[01:10:29] error[E0599]: no method named `offset` found for type `core::ptr::NonNull<u8>` in the current scope
[01:10:29]    --> liballoc/heap.rs:329:27
[01:10:29]     |
[01:10:29] 329 |             let end = ptr.offset(layout.size() as isize);
[01:10:29]     |                           ^^^^^^
[01:10:29]
[01:10:29] error[E0614]: type `core::ptr::NonNull<u8>` cannot be dereferenced
[01:10:29]    --> liballoc/heap.rs:332:28
[01:10:29]     |
[01:10:29] 332 |                 assert_eq!(*i, 0);
[01:10:29]     |                            ^^
[01:10:29]
[01:10:29] error[E0599]: no method named `offset` found for type `core::ptr::NonNull<u8>` in the current scope
[01:10:29]    --> liballoc/heap.rs:333:23
[01:10:29]     |
[01:10:29] 333 |                 i = i.offset(1);
[01:10:29]     |                       ^^^^^^
[01:10:29]
[01:10:29] error[E0605]: non-primitive cast: `std::ptr::NonNull<u8>` as `usize`
[01:10:29]   --> liballoc/../liballoc/tests/heap.rs:37:24
[01:10:29]    |
[01:10:29] 37 |             assert_eq!((ptr as usize) % align, 0, "Got a pointer less aligned than requested")
[01:10:29]    |                        ^^^^^^^^^^^^^^
[01:10:29]    |
[01:10:29]    = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
[01:10:29]
[01:10:32] error: aborting due to 3 previous errors
[01:10:32]
[01:10:32] Some errors occurred: E0599, E0614.
[01:10:32] For more information about an error, try `rustc --explain E0599`.
[01:10:32] error: Could not compile `alloc`.
[01:10:32] warning: build failed, waiting for other jobs to finish...
[01:10:34] error: aborting due to previous error
[01:10:34]
[01:10:34] For more information about this error, try `rustc --explain E0605`.
[01:10:34] error: Could not compile `alloc`.
[01:10:34]
[01:10:34] To learn more, run the command again with --verbose.
[01:10:34]
[01:10:34]
[01:10:34] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "alloc" "--" "--quiet"
[01:10:34] expected success, got: exit code: 101
[01:10:34]
[01:10:34]
[01:10:34] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:10:34] Build completed unsuccessfully in 0:28:52
[01:10:34] make: *** [check] Error 1
[01:10:34] Makefile:58: recipe for target 'check' failed
---
$ cat obj/tmp/sccache.log
---
travis_fold:end:travis_time:start:11410850
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:11410850:start=1522729074964265890,finish=1522729074971621330,duration=7355440
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0a07c160
$ dmesg | grep -i kill
[   10.638996] init: failsafe main process (1094) killed by TERM signal

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.

@TimNN
Copy link
Contributor

TimNN commented Apr 3, 2018

Your PR failed on Travis. 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.
[00:00:47] configure: rust.quiet-tests     := True
---
[00:43:22] .........................................................................i..........................
[00:43:28] ................i...................................................................................
---
[00:44:04] ............................................................................................i.......
[00:44:11] ................................................................i...................................
---
[00:45:07] .............................................i......................................................
---
[00:49:11] .............................i......................................................................
[00:49:26] ..............................................................i.....................................
[00:49:41] ...............................................i....................................................
[00:50:02] ....................................................................................................
[00:50:24] ....................................................................................................
[00:50:46] ....................................................................................................
[00:51:11] .i................................................................................................i.
[00:51:38] ...............................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:51:48] .....................
[00:52:19] ....................................................................................................
[00:52:56] ...............................................................ii...................................
[00:53:41] ..........................i....................................................i.ii..test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:53:49] ...............
[00:54:30] .......................................................................................iiiiiii......
---
[00:56:29] ....................................i...............................................................
[00:56:36] ....................................................................................................
[00:56:44] ..................i............................................................ii.iii...............
[00:56:51] ....................................................................................................
[00:56:59] ........i..............................i............................................................
[00:57:07] ....................................................................................................
[00:57:14] .....................i..............................................................................
[00:57:22] ....................................................................................................
[00:57:32] ....................................................................................................
[00:57:43] ....................................................................................................
[00:57:54] ....................................................................................................
[00:58:08] ....................................................................................................
[00:58:17] ..............i.....................................................................................
[00:58:27] .................i..ii..............................................................................
[00:58:37] ....................................................................................................
[00:58:47] ....................................................................................................
[00:58:56] ....................................................................................i...............
[00:59:07] ..............................i.....................................................................
---
[00:59:44] ...........................i........................................................................
[00:59:46] ....................................................................i...............................
[00:59:47] ................i.......................................................
---
[01:00:02] ...........i........................
---
[01:00:32] i...i..ii....i.............ii........iii......i..i...i...ii..i..i..ii.....
---
[01:00:36] i.......i......................i......
---
[01:01:14] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[01:01:15] ....ii...
---
[01:10:50] ...i................................................................................................
---
[01:12:54] ......................................i.............................................................
[01:13:15] ....................................................................................................
[01:13:35] .............................................i......................................................
---
[01:15:12] ........................................................ii..........................................
---
[01:16:18] .............................................................i......................................
---
[01:21:18] ii..................................................................................................
[01:21:38] ....................................................................................................
[01:21:54] ...................iii......i......i...i......i.....................................................
[01:22:04] ....................................................................................................
[01:22:20] ........................................iiii........ii..............................................
[01:22:31] ....................................................................................................
[01:22:48] .......................................................................................i............

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.

unsafe {
let p = unsafe {
if layout.size() == 0 {
NonNull::new_unchecked(mem::align_of::<T>() as *mut u8)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe NonNull::<T>::dangling().cast()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that #48333 removes this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But there's another in raw_vec.rs.

use core::heap;
pub use core::heap::{AllocErr, CannotReallocInPlace, CollectionAllocErr, Layout};
#[cfg(not(stage0))]
pub use core::heap::{Alloc, Excess};
#[doc(hidden)]
pub mod __core {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can #[cfg(stage0)] be added to this __core module?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right, because the only use of that __core was the #[global_allocator] expansion. Neat!

@pietroalbini pietroalbini added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 3, 2018
@SimonSapin
Copy link
Contributor

It /might/ make sense to wait for GlobalAlloc to go in first, so that #[global_allocator] only breaks once. But I still wanted to put this out there, get feedback on the change itself.

The change looks good to me. As you said, since we have more breaking changes upcoming it might be better to batch them so that Nightly users only need to do one migration. I’m working on GlobalAlloc today, I think I can integrate this commit in my upcoming PR. If my further changes turn out not to be ready for a while we can still land this to avoid bitrotting.

@SimonSapin SimonSapin assigned SimonSapin and unassigned withoutboats Apr 3, 2018
@SimonSapin SimonSapin added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 3, 2018
@bors
Copy link
Contributor

bors commented Apr 4, 2018

☔ The latest upstream changes (presumably #48333) made this pull request unmergeable. Please resolve the merge conflicts.

As discussed in rust-lang#32838 (comment)
and following, instead of *mut pointers, use NonNull for the allocator
API.

One issue is that older rustc versions, used to bootstrap the compiler,
expands #[global_allocator], used in various places including libstd or
librustc_[almt]san, to code that uses the Alloc trait, so changes to
that trait make bootstrapping fail. Thankfully, it does so through the
location of the Alloc trait before 94d1970
so we can use at our advantage by making stage0 expose the old API as
alloc::heap::Alloc.

At the same time, we change the expansion for #[global_allocator] to use
the new trait location under core, which will allow newer versions of
rustc to bootstrap stage0 as well, despite the workaround described above.
@glandium
Copy link
Contributor Author

glandium commented Apr 4, 2018

Rebased on top of #48333.

@glandium
Copy link
Contributor Author

glandium commented Apr 4, 2018

Also, addressed review comments.

@SimonSapin
Copy link
Contributor

#49669 includes this change (and more).

@bors bors closed this in fddf51e Apr 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants