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

Add Arc::{incr,decr}_strong_count #70733

Merged
merged 1 commit into from
May 8, 2020
Merged

Add Arc::{incr,decr}_strong_count #70733

merged 1 commit into from
May 8, 2020

Conversation

yoshuawuyts
Copy link
Member

@yoshuawuyts yoshuawuyts commented Apr 3, 2020

This adds two unsafe methods to Arc: incr_strong_count and decr_strong_count. A suggestion to add methods to change the strong count in Arc came up in during review in #68700 (comment), and from asking a few people this seemed like generally useful to have.

References:

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 3, 2020
@rust-highfive
Copy link
Collaborator

The job mingw-check 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.
2020-04-03T11:15:28.0561040Z ========================== Starting Command Output ===========================
2020-04-03T11:15:28.0563526Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/864e5e47-0a09-49fb-b61f-d7acbc79684c.sh
2020-04-03T11:15:28.0563892Z 
2020-04-03T11:15:28.0568964Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-03T11:15:28.0587931Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T11:15:28.0591148Z Task         : Get sources
2020-04-03T11:15:28.0591458Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-03T11:15:28.0591758Z Version      : 1.0.0
2020-04-03T11:15:28.0591978Z Author       : Microsoft
---
2020-04-03T11:15:29.0492975Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-03T11:15:29.0499804Z ##[command]git config gc.auto 0
2020-04-03T11:15:29.0504933Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-03T11:15:29.0509731Z ##[command]git config --get-all http.proxy
2020-04-03T11:15:29.0517078Z ##[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/70733/merge:refs/remotes/pull/70733/merge
---
2020-04-03T11:17:58.0244746Z  ---> 3fc1b512c57b
2020-04-03T11:17:58.0244986Z Step 6/7 : ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
2020-04-03T11:17:58.0245362Z  ---> Using cache
2020-04-03T11:17:58.0245689Z  ---> 5ee4295733f4
2020-04-03T11:17:58.0247037Z Step 7/7 : ENV SCRIPT python2.7 ../x.py test src/tools/expand-yaml-anchors &&            python2.7 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu &&            python2.7 ../x.py build --stage 0 src/tools/build-manifest &&            python2.7 ../x.py test --stage 0 src/tools/compiletest &&            python2.7 ../x.py test src/tools/tidy &&            /scripts/validate-toolstate.sh
2020-04-03T11:17:58.0248767Z  ---> 3d07a0fa42fe
2020-04-03T11:17:58.0275677Z Successfully built 3d07a0fa42fe
2020-04-03T11:17:58.0336956Z Successfully tagged rust-ci:latest
2020-04-03T11:17:58.0852020Z Built container sha256:3d07a0fa42feb5754fc13bb2f7010ebe13e4b8b8cdbebed0c75d8da320c8c8ad
2020-04-03T11:17:58.0852020Z Built container sha256:3d07a0fa42feb5754fc13bb2f7010ebe13e4b8b8cdbebed0c75d8da320c8c8ad
2020-04-03T11:17:58.0867983Z Looks like docker image is the same as before, not uploading
2020-04-03T11:18:04.8231560Z [CI_JOB_NAME=mingw-check]
2020-04-03T11:18:04.8613682Z [CI_JOB_NAME=mingw-check]
2020-04-03T11:18:04.8625386Z == clock drift check ==
2020-04-03T11:18:04.8634715Z   local time: Fri Apr  3 11:18:04 UTC 2020
2020-04-03T11:18:04.9304595Z   network time: Fri, 03 Apr 2020 11:18:04 GMT
2020-04-03T11:18:04.9331593Z Starting sccache server...
2020-04-03T11:18:05.0212032Z configure: processing command line
2020-04-03T11:18:05.0212345Z configure: 
2020-04-03T11:18:05.0213233Z configure: rust.parallel-compiler := True
---
2020-04-03T11:19:52.4888103Z     Checking alloc v0.0.0 (/checkout/src/liballoc)
2020-04-03T11:19:52.7441881Z error[E0424]: expected value, found module `self`
2020-04-03T11:19:52.7442586Z    --> src/liballoc/sync.rs:769:24
2020-04-03T11:19:52.7443113Z     |
2020-04-03T11:19:52.7443886Z 757 | /     pub unsafe fn increment_strong_count(this: &Self) {
2020-04-03T11:19:52.7445102Z 758 | |         // Using a relaxed ordering is alright here, as knowledge of the
2020-04-03T11:19:52.7446155Z 759 | |         // original reference prevents other threads from erroneously deleting
2020-04-03T11:19:52.7447705Z ...   |
2020-04-03T11:19:52.7447705Z ...   |
2020-04-03T11:19:52.7448505Z 769 | |         let old_size = self.inner().strong.fetch_add(1, Relaxed);
2020-04-03T11:19:52.7449649Z     | |                        ^^^^ `self` value is a keyword only available in methods with a `self` parameter
2020-04-03T11:19:52.7451134Z 782 | |         }
2020-04-03T11:19:52.7451876Z 783 | |     }
2020-04-03T11:19:52.7452696Z     | |_____- this function doesn't have a `self` parameter
2020-04-03T11:19:52.7453069Z 
2020-04-03T11:19:52.7453069Z 
2020-04-03T11:19:52.7471326Z error[E0424]: expected value, found module `self`
2020-04-03T11:19:52.7472005Z    --> src/liballoc/sync.rs:791:9
2020-04-03T11:19:52.7472531Z     |
2020-04-03T11:19:52.7473502Z 788 | /     pub unsafe fn decrement_strong_count(this: &Self) {
2020-04-03T11:19:52.7474629Z 789 | |         // Because `fetch_sub` is already atomic, we do not need to synchronize
2020-04-03T11:19:52.7475681Z 790 | |         // with other threads unless we are going to delete the object.
2020-04-03T11:19:52.7476645Z 791 | |         self.inner().strong.fetch_sub(1, Release);
2020-04-03T11:19:52.7477739Z     | |         ^^^^ `self` value is a keyword only available in methods with a `self` parameter
2020-04-03T11:19:52.7479499Z     | |_____- this function doesn't have a `self` parameter
2020-04-03T11:19:52.7479855Z 
2020-04-03T11:19:52.8786523Z error[E0545]: `issue` must be a non-zero numeric string or "none"
2020-04-03T11:19:52.8787275Z    --> src/liballoc/sync.rs:756:46
2020-04-03T11:19:52.8787275Z    --> src/liballoc/sync.rs:756:46
2020-04-03T11:19:52.8787773Z     |
2020-04-03T11:19:52.8788448Z 756 |     #[unstable(feature = "arc_mutate_count", issue = "0")]
2020-04-03T11:19:52.8790134Z     |                                                      |
2020-04-03T11:19:52.8790134Z     |                                                      |
2020-04-03T11:19:52.8791082Z     |                                                      `issue` must not be "0", use "none" instead
2020-04-03T11:19:52.8792013Z error[E0545]: `issue` must be a non-zero numeric string or "none"
2020-04-03T11:19:52.8792680Z    --> src/liballoc/sync.rs:787:46
2020-04-03T11:19:52.8793170Z     |
2020-04-03T11:19:52.8793170Z     |
2020-04-03T11:19:52.8793819Z 787 |     #[unstable(feature = "arc_mutate_count", issue = "0")]
2020-04-03T11:19:52.8795510Z     |                                                      |
2020-04-03T11:19:52.8795510Z     |                                                      |
2020-04-03T11:19:52.8796416Z     |                                                      `issue` must not be "0", use "none" instead
2020-04-03T11:19:53.5983802Z     Checking rustc-demangle v0.1.16
2020-04-03T11:19:53.7338821Z error[E0599]: no method named `increment_strong_count` found for reference `&sync::Arc<T>` in the current scope
2020-04-03T11:19:53.7339679Z     --> src/liballoc/sync.rs:1016:23
2020-04-03T11:19:53.7340213Z      |
---
2020-04-03T11:19:53.8811183Z expected success, got: exit code: 101
2020-04-03T11:19:53.8811608Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap check
2020-04-03T11:19:53.8811953Z Build completed unsuccessfully in 0:01:48
2020-04-03T11:19:53.8864681Z == clock drift check ==
2020-04-03T11:19:53.8875465Z   local time: Fri Apr  3 11:19:53 UTC 2020
2020-04-03T11:19:54.0516021Z   network time: Fri, 03 Apr 2020 11:19:54 GMT
2020-04-03T11:19:55.1030745Z 
2020-04-03T11:19:55.1030745Z 
2020-04-03T11:19:55.1100617Z ##[error]Bash exited with code '1'.
2020-04-03T11:19:55.1114291Z ##[section]Finishing: Run build
2020-04-03T11:19:55.1158257Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T11:19:55.1163116Z Task         : Get sources
2020-04-03T11:19:55.1163472Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-03T11:19:55.1163798Z Version      : 1.0.0
2020-04-03T11:19:55.1164051Z Author       : Microsoft
2020-04-03T11:19:55.1164051Z Author       : Microsoft
2020-04-03T11:19:55.1164652Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-03T11:19:55.1165077Z ==============================================================================
2020-04-03T11:19:55.4507719Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-03T11:19:55.4551405Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T11:19:55.4645150Z Cleaning up task key
2020-04-03T11:19:55.4646682Z Start cleaning up orphan processes.
2020-04-03T11:19:55.4834392Z Terminate orphan process: pid (3552) (python)
2020-04-03T11:19:55.4965122Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

I think historically the common use cases for these functions have been on the raw pointer from Arc::into_raw; maybe it's worth making these take a raw pointer instead? (Both would need to be unsafe then).

src/liballoc/sync.rs Outdated Show resolved Hide resolved
@tmiasko
Copy link
Contributor

tmiasko commented Apr 3, 2020

Any examples where proposed implementation of decrement_strong_count (that takes Arc by reference and so never drops it) would be useful?

@yoshuawuyts
Copy link
Member Author

@tmiasko I only added that method for the purpose of symmetry; if we're able to increment it seems desirable to also be able to decrement. But perhaps you're right and it doesn't serve a purpose.

@yoshuawuyts
Copy link
Member Author

I think historically the common use cases for these functions have been on the raw pointer from Arc::into_raw; maybe it's worth making these take a raw pointer instead?

@Mark-Simulacrum I'm not quite sure I follow what you mean? Are you referring to changing the external API, the internal implementation, or both?


@tmiasko I've gone and removed the decerement_strong_count method as I don't have a clear motivating use case to add it.

@yoshuawuyts yoshuawuyts changed the title Add Arc::{increment,decrement}_strong_count Add Arc::increment_strong_count Apr 3, 2020
@Mark-Simulacrum
Copy link
Member

@Mark-Simulacrum I'm not quite sure I follow what you mean? Are you referring to changing the external API, the internal implementation, or both?

I'm saying that I think the more ergonomic API is probably something like

/// This increases the strong reference count on the `Arc<T>` associated with
/// the provided pointer.
/// 
/// # Safety
///
/// The pointer must have been obtained through `Arc::into_raw`, and the
/// associated `Arc` instance must be valid (i.e. the strong count must be at
/// least 1) for the duration of this method.
unsafe fn increment_strong_count(ptr: *const T);
unsafe fn decrement_strong_count(ptr: *const T);

These functions would internally do the from_raw and into_raw dance; with this API the decrement_strong_count function is even more unnecessary as it's equivalent to drop(Arc::from_raw(ptr)) AFAICT, though perhaps possible to implement in a less expensive way? Not sure.

@yoshuawuyts
Copy link
Member Author

@Mark-Simulacrum Ahh, now I see. Yes, I agree fully. Going to go ahead and change things to match your suggestion (:

@ghost
Copy link

ghost commented Apr 3, 2020

I'd just like to say I'm excited for this feature because it will make writing certain kinds of unsafe code much easier. :)

Bumping reference counts using mem::forget() is surprisingly hard. Even programmers with lots of experience in unsafe Rust make mistakes, even in trivial examples that go through code review.

Example: https://twitter.com/stjepang/status/1217906121614286848

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 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.
2020-04-03T15:13:48.3139345Z ========================== Starting Command Output ===========================
2020-04-03T15:13:48.3142294Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/21736eec-bedb-4ae2-8abe-cc009d2ca8b5.sh
2020-04-03T15:13:48.3142620Z 
2020-04-03T15:13:48.3147176Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-03T15:13:48.3170346Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T15:13:48.3174227Z Task         : Get sources
2020-04-03T15:13:48.3174605Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-03T15:13:48.3174968Z Version      : 1.0.0
2020-04-03T15:13:48.3175289Z Author       : Microsoft
---
2020-04-03T15:13:49.3260263Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-03T15:13:49.3266650Z ##[command]git config gc.auto 0
2020-04-03T15:13:49.3270979Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-03T15:13:49.3275294Z ##[command]git config --get-all http.proxy
2020-04-03T15:13:49.3282692Z ##[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/70733/merge:refs/remotes/pull/70733/merge
---
2020-04-03T15:16:10.3537268Z Looks like docker image is the same as before, not uploading
2020-04-03T15:16:18.2985421Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-03T15:16:18.3262288Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-03T15:16:18.3291277Z == clock drift check ==
2020-04-03T15:16:18.3301542Z   local time: Fri Apr  3 15:16:18 UTC 2020
2020-04-03T15:16:18.4282293Z   network time: Fri, 03 Apr 2020 15:16:18 GMT
2020-04-03T15:16:18.4306407Z Starting sccache server...
2020-04-03T15:16:18.5085835Z configure: processing command line
2020-04-03T15:16:18.5086163Z configure: 
2020-04-03T15:16:18.5087128Z configure: rust.dist-src        := False
---
2020-04-03T15:20:56.4211589Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-03T15:20:57.7457894Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-03T15:20:59.2181045Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-03T15:20:59.9995538Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-03T15:21:08.2295143Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-03T15:21:10.0209791Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-03T15:21:14.4345326Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-03T15:21:17.7579178Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-03T15:21:26.8290566Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-03T15:41:30.4102164Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-03T15:41:31.9950422Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-03T15:41:33.8467144Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-03T15:41:35.1322729Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-03T15:41:45.4264181Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-03T15:41:47.8125675Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-03T15:41:52.5838480Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-03T15:41:57.5727026Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-03T15:42:08.4829936Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-03T16:05:27.4782207Z .................................................................................................... 1700/9871
2020-04-03T16:05:31.1181552Z .................................................................................................... 1800/9871
2020-04-03T16:05:39.2142034Z ...............................................................................................i.... 1900/9871
2020-04-03T16:05:46.6953899Z .................................................................................................... 2000/9871
2020-04-03T16:05:52.8033559Z .....................................................................................iiiii.......... 2100/9871
2020-04-03T16:06:12.2964067Z .................................................................................................... 2300/9871
2020-04-03T16:06:14.2498119Z .................................................................................................... 2400/9871
2020-04-03T16:06:16.3907262Z .................................................................................................... 2500/9871
2020-04-03T16:06:21.9430364Z .................................................................................................... 2600/9871
---
2020-04-03T16:08:58.4518761Z ...........................................................i...............i........................ 5000/9871
2020-04-03T16:09:05.7193585Z .................................................................................................... 5100/9871
2020-04-03T16:09:12.3627466Z .................................................................................................... 5200/9871
2020-04-03T16:09:17.0269428Z ....i............................................................................................... 5300/9871
2020-04-03T16:09:25.9713943Z ...........................................................................................ii.ii.... 5400/9871
2020-04-03T16:09:30.0528705Z ....i...i........................................................................................... 5500/9871
2020-04-03T16:09:37.8966974Z ....................................i............................................................... 5700/9871
2020-04-03T16:09:46.7423484Z ........................................................ii....................................i..... 5800/9871
2020-04-03T16:09:53.4485076Z .................................................................................................... 5900/9871
2020-04-03T16:09:57.8065219Z .................................................................................................... 6000/9871
2020-04-03T16:09:57.8065219Z .................................................................................................... 6000/9871
2020-04-03T16:10:06.1678522Z ........................................................................................ii...i..ii.. 6100/9871
2020-04-03T16:10:25.4798295Z .................................................................................................... 6300/9871
2020-04-03T16:10:29.8719200Z .................................................................................................... 6400/9871
2020-04-03T16:10:32.5806564Z .................................................................................................... 6500/9871
2020-04-03T16:10:32.5806564Z .................................................................................................... 6500/9871
2020-04-03T16:10:44.0423347Z ..................i..ii............................................................................. 6600/9871
2020-04-03T16:11:03.9848436Z .................................................................................................... 6800/9871
2020-04-03T16:11:06.0248100Z ..................i................................................................................. 6900/9871
2020-04-03T16:11:08.0438843Z .................................................................................................... 7000/9871
2020-04-03T16:11:10.1238136Z .........................................................i.......................................... 7100/9871
---
2020-04-03T16:12:42.5376102Z .................................................................................................... 7800/9871
2020-04-03T16:12:46.8402595Z .................................................................................................... 7900/9871
2020-04-03T16:12:52.3616820Z .................................................................................................... 8000/9871
2020-04-03T16:12:59.9087273Z .....................i.............................................................................. 8100/9871
2020-04-03T16:13:07.4523723Z ......................................................................iiiiiiiiii.i.................. 8200/9871
2020-04-03T16:13:22.2573949Z ..............i......i.............................................................................. 8400/9871
2020-04-03T16:13:26.7045185Z .................................................................................................... 8500/9871
2020-04-03T16:13:37.2257883Z .................................................................................................... 8600/9871
2020-04-03T16:13:48.4168765Z .................................................................................................... 8700/9871
---
2020-04-03T16:16:02.0019956Z en") not skipped for "bootstrap::test::Codegen" -- not in ["src/tools/tidy"]
2020-04-03T16:16:02.0203781Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-03T16:16:02.2202925Z 
2020-04-03T16:16:02.2203323Z running 183 tests
2020-04-03T16:16:04.7635382Z iiii......i............ii.i..ii.ii...i....i...........i............i..i..................i....i..... 100/183
2020-04-03T16:16:07.1163792Z .......i.i.i...iii..iiiiiiiiiiiiiiii........................iii............ii......
2020-04-03T16:16:07.1175254Z 
2020-04-03T16:16:07.1176696Z  finished in 5.096
2020-04-03T16:16:07.1178745Z Suite("src/test/codegen-units") not skipped for "bootstrap::test::CodegenUnits" -- not in ["src/tools/tidy"]
2020-04-03T16:16:07.1353829Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-03T16:16:09.0514289Z Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
2020-04-03T16:16:09.0690653Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-03T16:16:09.2139845Z 
2020-04-03T16:16:09.2140318Z running 9 tests
2020-04-03T16:16:09.2141647Z iiiiiiiii
2020-04-03T16:16:09.2142799Z 
2020-04-03T16:16:09.2142992Z  finished in 0.145
2020-04-03T16:16:09.2150877Z Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
2020-04-03T16:16:09.2335655Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-03T16:16:27.6664641Z Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
2020-04-03T16:16:27.6880039Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-03T16:16:27.8612083Z 
2020-04-03T16:16:27.8612472Z running 115 tests
2020-04-03T16:16:40.9941031Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii.........i.....i..i.......ii.i.ii.. 100/115
2020-04-03T16:16:42.6044588Z ...iiii.....ii.
2020-04-03T16:16:42.6047267Z 
2020-04-03T16:16:42.6047573Z  finished in 14.916
2020-04-03T16:16:42.6053297Z Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
2020-04-03T16:16:42.6056639Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-03T16:27:12.7055456Z ---- sync.rs - sync::Arc<T>::increment_strong_count (line 771) stdout ----
2020-04-03T16:27:12.7056223Z error[E0658]: use of unstable library feature 'arc_increment_strong_count'
2020-04-03T16:27:12.7056778Z  --> sync.rs:775:6
2020-04-03T16:27:12.7057051Z   |
2020-04-03T16:27:12.7057343Z 7 | five.increment_strong_count();
2020-04-03T16:27:12.7057926Z   |
2020-04-03T16:27:12.7058317Z   = help: add `#![feature(arc_increment_strong_count)]` to the crate attributes to enable
2020-04-03T16:27:12.7058657Z 
2020-04-03T16:27:12.7058930Z error: aborting due to previous error
---
2020-04-03T16:27:12.7135203Z 
2020-04-03T16:27:12.7143541Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-04-03T16:27:12.7144082Z Build completed unsuccessfully in 1:09:26
2020-04-03T16:27:12.7199548Z == clock drift check ==
2020-04-03T16:27:13.1875247Z   local time: Fri Apr  3 16:27:12 UTC 2020
2020-04-03T16:27:13.1881135Z   network time: Fri, 03 Apr 2020 16:27:12 GMT
2020-04-03T16:27:13.1883319Z 
2020-04-03T16:27:13.1883319Z 
2020-04-03T16:27:13.1923669Z ##[error]Bash exited with code '1'.
2020-04-03T16:27:13.1936565Z ##[section]Finishing: Run build
2020-04-03T16:27:13.1982192Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T16:27:13.1987297Z Task         : Get sources
2020-04-03T16:27:13.1987654Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-03T16:27:13.1987964Z Version      : 1.0.0
2020-04-03T16:27:13.1988191Z Author       : Microsoft
2020-04-03T16:27:13.1988191Z Author       : Microsoft
2020-04-03T16:27:13.1988557Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-03T16:27:13.1988958Z ==============================================================================
2020-04-03T16:27:13.5123927Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-03T16:27:13.5128087Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T16:27:13.5207259Z Cleaning up task key
2020-04-03T16:27:13.5208477Z Start cleaning up orphan processes.
2020-04-03T16:27:13.5373071Z Terminate orphan process: pid (3477) (python)
2020-04-03T16:27:13.5564779Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@yoshuawuyts
Copy link
Member Author

yoshuawuyts commented Apr 3, 2020

Okay, did another pass. The two methods are now:

  • inc_strong_count
  • dec_strong_count

As per @Mark-Simulacrum's suggestion they take a pointer, which has improved practical use.

Naming

Something I'm unsure about is the naming. There are several considerations:

  • All methods in Arc operate on strong_count. In order to change the value of weak_count it should go through a Weak reference.
  • A lot of methods in std that take a pointer use ptr or raw in their name.
  • The inc_ and dec_ prefixes don't exist in std yet.
    • Instead atomics use fetch_add and fetch_sub to increment and decrement by a given value.

I'm wondering whether Arc::ptr_add(ptr, val) and Arc::ptr_sub(ptr, val) would be better names. They no longer mention strong_count which may be needed, but also Arc::ptr_add_strong_count(ptr, val) seems too verbose. This is probably not something that needs to be resolved immediately, but does require some consideration.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 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.
2020-04-03T18:32:10.3124468Z ========================== Starting Command Output ===========================
2020-04-03T18:32:10.3127417Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/bad288ad-5b0e-4bbd-ab13-ad768f079a8e.sh
2020-04-03T18:32:10.3127743Z 
2020-04-03T18:32:10.3132337Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-03T18:32:10.3155069Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T18:32:10.3158540Z Task         : Get sources
2020-04-03T18:32:10.3158830Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-03T18:32:10.3159112Z Version      : 1.0.0
2020-04-03T18:32:10.3159303Z Author       : Microsoft
---
2020-04-03T18:32:11.3207752Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-03T18:32:11.3212602Z ##[command]git config gc.auto 0
2020-04-03T18:32:11.3215869Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-03T18:32:11.3219210Z ##[command]git config --get-all http.proxy
2020-04-03T18:32:11.3224714Z ##[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/70733/merge:refs/remotes/pull/70733/merge
---
2020-04-03T18:34:12.2404788Z Looks like docker image is the same as before, not uploading
2020-04-03T18:34:19.0110712Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-03T18:34:19.0334521Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-03T18:34:19.0361159Z == clock drift check ==
2020-04-03T18:34:19.0368945Z   local time: Fri Apr  3 18:34:19 UTC 2020
2020-04-03T18:34:19.1067119Z   network time: Fri, 03 Apr 2020 18:34:19 GMT
2020-04-03T18:34:19.1091783Z Starting sccache server...
2020-04-03T18:34:19.1937015Z configure: processing command line
2020-04-03T18:34:19.1938008Z configure: 
2020-04-03T18:34:19.1939727Z configure: rust.dist-src        := False
---
2020-04-03T18:38:58.8737356Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-03T18:39:00.3164940Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-03T18:39:01.8863099Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-03T18:39:02.9234372Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-03T18:39:11.9461837Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-03T18:39:14.2468584Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-03T18:39:18.4020942Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-03T18:39:22.2593591Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-03T18:39:31.0156188Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-03T18:59:09.8191103Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-03T18:59:11.4771867Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-03T18:59:13.3455251Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-03T18:59:14.6739378Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-03T18:59:25.4163260Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-03T18:59:27.6588772Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-03T18:59:32.8797255Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-03T18:59:38.1175381Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-03T18:59:49.1561509Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-03T19:22:05.1803328Z .................................................................................................... 1700/9872
2020-04-03T19:22:08.8216159Z .................................................................................................... 1800/9872
2020-04-03T19:22:16.6974021Z ...............................................................................................i.... 1900/9872
2020-04-03T19:22:23.6043067Z .................................................................................................... 2000/9872
2020-04-03T19:22:29.2303316Z .....................................................................................iiiii.......... 2100/9872
2020-04-03T19:22:46.7815486Z .................................................................................................... 2300/9872
2020-04-03T19:22:48.5917416Z .................................................................................................... 2400/9872
2020-04-03T19:22:50.5475431Z .................................................................................................... 2500/9872
2020-04-03T19:22:55.8514613Z .................................................................................................... 2600/9872
---
2020-04-03T19:25:25.8247131Z ...........................................................i...............i........................ 5000/9872
2020-04-03T19:25:32.0747299Z .................................................................................................... 5100/9872
2020-04-03T19:25:38.7845545Z .................................................................................................... 5200/9872
2020-04-03T19:25:43.5006385Z ....i............................................................................................... 5300/9872
2020-04-03T19:25:52.7296834Z ............................................................................................ii.ii... 5400/9872
2020-04-03T19:25:56.8257865Z .....i...i.......................................................................................... 5500/9872
2020-04-03T19:26:04.7263004Z .....................................i.............................................................. 5700/9872
2020-04-03T19:26:13.9249290Z .........................................................ii....................................i.... 5800/9872
2020-04-03T19:26:21.2766043Z .................................................................................................... 5900/9872
2020-04-03T19:26:25.6143102Z .................................................................................................... 6000/9872
2020-04-03T19:26:25.6143102Z .................................................................................................... 6000/9872
2020-04-03T19:26:33.7240690Z .........................................................................................ii...i..ii. 6100/9872
2020-04-03T19:26:50.3628110Z .................................................................................................... 6300/9872
2020-04-03T19:26:55.7303953Z .................................................................................................... 6400/9872
2020-04-03T19:26:58.0273359Z .................................................................................................... 6500/9872
2020-04-03T19:26:58.0273359Z .................................................................................................... 6500/9872
2020-04-03T19:27:07.8783036Z ...................i..ii............................................................................ 6600/9872
2020-04-03T19:27:24.2953589Z .................................................................................................... 6800/9872
2020-04-03T19:27:25.9884250Z ...................i................................................................................ 6900/9872
2020-04-03T19:27:28.0031372Z .................................................................................................... 7000/9872
2020-04-03T19:27:30.1403487Z ..........................................................i......................................... 7100/9872
---
2020-04-03T19:28:49.1462001Z .................................................................................................... 7800/9872
2020-04-03T19:28:52.8771555Z .................................................................................................... 7900/9872
2020-04-03T19:28:57.7111412Z .................................................................................................... 8000/9872
2020-04-03T19:29:04.6685434Z ......................i............................................................................. 8100/9872
2020-04-03T19:29:12.0610770Z .......................................................................iiiiiiiiii.i................. 8200/9872
2020-04-03T19:29:26.7795138Z ...............i......i............................................................................. 8400/9872
2020-04-03T19:29:31.4054790Z .................................................................................................... 8500/9872
2020-04-03T19:29:42.3389102Z .................................................................................................... 8600/9872
2020-04-03T19:29:54.2988194Z .................................................................................................... 8700/9872
---
2020-04-03T19:31:49.7832904Z Suite("src/test/codegen") not skipped for "bootstrap::test::Codegen" -- not in ["src/tools/tidy"]
2020-04-03T19:31:49.7999132Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-03T19:31:49.9598167Z 
2020-04-03T19:31:49.9598742Z running 183 tests
2020-04-03T19:31:52.4901049Z iiii......i............ii.i..iiii....i....i...........i............i..i..................i....i..... 100/183
2020-04-03T19:31:54.6348160Z .......i.i.i...iii..iiiiiiiiiiiiiiii.......................iii.............ii......
2020-04-03T19:31:54.6354361Z 
2020-04-03T19:31:54.6359686Z  finished in 4.836
2020-04-03T19:31:54.6364316Z Suite("src/test/codegen-units") not skipped for "bootstrap::test::CodegenUnits" -- not in ["src/tools/tidy"]
2020-04-03T19:31:54.6532219Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-03T19:31:56.5877365Z Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
2020-04-03T19:31:56.6065366Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-03T19:31:56.7404705Z 
2020-04-03T19:31:56.7405631Z running 9 tests
2020-04-03T19:31:56.7407122Z iiiiiiiii
2020-04-03T19:31:56.7408177Z 
2020-04-03T19:31:56.7408418Z  finished in 0.134
2020-04-03T19:31:56.7412954Z Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
2020-04-03T19:31:56.7600069Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-03T19:32:15.3883954Z Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
2020-04-03T19:32:15.4077640Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-03T19:32:15.5617441Z 
2020-04-03T19:32:15.5617716Z running 115 tests
2020-04-03T19:32:26.9746529Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii.........i.....i..i.......ii.i.ii.. 100/115
2020-04-03T19:32:28.5065946Z ...iiii.....ii.
2020-04-03T19:32:28.5067837Z 
2020-04-03T19:32:28.5068529Z  finished in 13.099
2020-04-03T19:32:28.5074719Z Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
2020-04-03T19:32:28.5077717Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-03T19:41:46.9774310Z error: aborting due to previous error
2020-04-03T19:41:46.9774505Z 
2020-04-03T19:41:46.9774918Z For more information about this error, try `rustc --explain E0658`.
2020-04-03T19:41:46.9775333Z Couldn't compile the test.
2020-04-03T19:41:46.9775797Z ---- sync.rs - sync::Arc<T>::inc_strong_count (line 767) stdout ----
2020-04-03T19:41:46.9776236Z error[E0599]: no method named `into_raw` found for struct `std::sync::Arc<{integer}>` in the current scope
2020-04-03T19:41:46.9776707Z   --> sync.rs:775:19
2020-04-03T19:41:46.9776922Z    |
2020-04-03T19:41:46.9777163Z 11 |    let ptr = five.into_raw() as *const ();
2020-04-03T19:41:46.9777786Z    |              |    |
2020-04-03T19:41:46.9778262Z    |              |    this is an associated function, not a method
2020-04-03T19:41:46.9778262Z    |              |    this is an associated function, not a method
2020-04-03T19:41:46.9778766Z    |              help: use associated function syntax instead: `std::sync::Arc::<{integer}>::into_raw`
2020-04-03T19:41:46.9779407Z    = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
2020-04-03T19:41:46.9779840Z    = note: the candidate is defined in an impl for the type `std::sync::Arc<_>`
2020-04-03T19:41:46.9780122Z 
2020-04-03T19:41:46.9780335Z error: aborting due to previous error
---
2020-04-03T19:41:46.9809628Z 
2020-04-03T19:41:46.9816421Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-04-03T19:41:46.9816700Z Build completed unsuccessfully in 1:06:02
2020-04-03T19:41:46.9862591Z == clock drift check ==
2020-04-03T19:41:46.9881755Z   local time: Fri Apr  3 19:41:46 UTC 2020
2020-04-03T19:41:47.0369164Z   network time: Fri, 03 Apr 2020 19:41:47 GMT
2020-04-03T19:41:47.3852569Z 
2020-04-03T19:41:47.3852569Z 
2020-04-03T19:41:47.3881569Z ##[error]Bash exited with code '1'.
2020-04-03T19:41:47.3902398Z ##[section]Finishing: Run build
2020-04-03T19:41:47.3949661Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T19:41:47.3953473Z Task         : Get sources
2020-04-03T19:41:47.3953718Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-03T19:41:47.3953945Z Version      : 1.0.0
2020-04-03T19:41:47.3954126Z Author       : Microsoft
2020-04-03T19:41:47.3954126Z Author       : Microsoft
2020-04-03T19:41:47.3954377Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-03T19:41:47.3954666Z ==============================================================================
2020-04-03T19:41:47.6398395Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-03T19:41:47.6435825Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T19:41:47.6523119Z Cleaning up task key
2020-04-03T19:41:47.6524023Z Start cleaning up orphan processes.
2020-04-03T19:41:47.6666955Z Terminate orphan process: pid (3419) (python)
2020-04-03T19:41:47.6793174Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 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.
2020-04-03T20:17:20.1444977Z ========================== Starting Command Output ===========================
2020-04-03T20:17:20.1447425Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/e817dbb2-2b25-4b74-9d5a-b2e6bbbe4603.sh
2020-04-03T20:17:20.1447695Z 
2020-04-03T20:17:20.1451510Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-03T20:17:20.1469254Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T20:17:20.1472313Z Task         : Get sources
2020-04-03T20:17:20.1472614Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-03T20:17:20.1472890Z Version      : 1.0.0
2020-04-03T20:17:20.1473075Z Author       : Microsoft
---
2020-04-03T20:17:21.1395228Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-03T20:17:21.1404425Z ##[command]git config gc.auto 0
2020-04-03T20:17:21.1411770Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-03T20:17:21.1419417Z ##[command]git config --get-all http.proxy
2020-04-03T20:17:21.1428488Z ##[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/70733/merge:refs/remotes/pull/70733/merge
---
2020-04-03T20:20:57.0637559Z Looks like docker image is the same as before, not uploading
2020-04-03T20:21:04.3998284Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-03T20:21:04.4246133Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-03T20:21:04.4271985Z == clock drift check ==
2020-04-03T20:21:04.4280266Z   local time: Fri Apr  3 20:21:04 UTC 2020
2020-04-03T20:21:04.7200949Z   network time: Fri, 03 Apr 2020 20:21:04 GMT
2020-04-03T20:21:04.7231847Z Starting sccache server...
2020-04-03T20:21:04.8151381Z configure: processing command line
2020-04-03T20:21:04.8151635Z configure: 
2020-04-03T20:21:04.8152507Z configure: rust.dist-src        := False
---
2020-04-03T20:26:02.2440016Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-03T20:26:03.5885736Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-03T20:26:05.0880637Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-03T20:26:06.1371302Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-03T20:26:14.4643865Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-03T20:26:16.5072632Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-03T20:26:20.6647132Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-03T20:26:24.5205638Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-03T20:26:33.4555950Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-03T20:47:28.8414721Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-03T20:47:30.5235304Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-03T20:47:32.4291699Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-03T20:47:34.7332741Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-03T20:47:44.1997159Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-03T20:47:46.6471707Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-03T20:47:51.6625131Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-03T20:47:56.7722094Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-03T20:48:07.4138892Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-03T21:12:22.6159557Z .................................................................................................... 1700/9872
2020-04-03T21:12:26.5160231Z .................................................................................................... 1800/9872
2020-04-03T21:12:35.1847366Z ...............................................................................................i.... 1900/9872
2020-04-03T21:12:42.7617339Z .................................................................................................... 2000/9872
2020-04-03T21:12:49.0086203Z .....................................................................................iiiii.......... 2100/9872
2020-04-03T21:13:09.7462301Z .................................................................................................... 2300/9872
2020-04-03T21:13:11.9615246Z .................................................................................................... 2400/9872
2020-04-03T21:13:14.2846184Z .................................................................................................... 2500/9872
2020-04-03T21:13:20.6712603Z .................................................................................................... 2600/9872
---
2020-04-03T21:16:13.0203249Z ...........................................................i...............i........................ 5000/9872
2020-04-03T21:16:20.3072957Z .................................................................................................... 5100/9872
2020-04-03T21:16:27.6212155Z .................................................................................................... 5200/9872
2020-04-03T21:16:32.5141005Z ....i............................................................................................... 5300/9872
2020-04-03T21:16:42.2739171Z ............................................................................................ii.ii... 5400/9872
2020-04-03T21:16:46.5595978Z .....i...i.......................................................................................... 5500/9872
2020-04-03T21:16:55.0004132Z .....................................i.............................................................. 5700/9872
2020-04-03T21:17:04.3734460Z .........................................................ii....................................i.... 5800/9872
2020-04-03T21:17:11.6870276Z .................................................................................................... 5900/9872
2020-04-03T21:17:16.3822781Z .................................................................................................... 6000/9872
2020-04-03T21:17:16.3822781Z .................................................................................................... 6000/9872
2020-04-03T21:17:25.5340748Z .........................................................................................ii...i..ii. 6100/9872
2020-04-03T21:17:45.5920348Z .................................................................................................... 6300/9872
2020-04-03T21:17:51.0978628Z .................................................................................................... 6400/9872
2020-04-03T21:17:53.7338015Z .................................................................................................... 6500/9872
2020-04-03T21:17:53.7338015Z .................................................................................................... 6500/9872
2020-04-03T21:18:05.5782356Z ...................i..ii............................................................................ 6600/9872
2020-04-03T21:18:25.0139705Z .................................................................................................... 6800/9872
2020-04-03T21:18:26.9351472Z ...................i................................................................................ 6900/9872
2020-04-03T21:18:28.8432944Z .................................................................................................... 7000/9872
2020-04-03T21:18:30.8941522Z ..........................................................i......................................... 7100/9872
---
2020-04-03T21:20:02.8431060Z .................................................................................................... 7800/9872
2020-04-03T21:20:07.0559626Z .................................................................................................... 7900/9872
2020-04-03T21:20:12.3912405Z .................................................................................................... 8000/9872
2020-04-03T21:20:19.8890969Z ......................i............................................................................. 8100/9872
2020-04-03T21:20:27.3205171Z .......................................................................iiiiiiiiii.i................. 8200/9872
2020-04-03T21:20:41.7831617Z ...............i......i............................................................................. 8400/9872
2020-04-03T21:20:46.2141346Z .................................................................................................... 8500/9872
2020-04-03T21:20:56.7077596Z .................................................................................................... 8600/9872
2020-04-03T21:21:07.9542301Z .................................................................................................... 8700/9872
---
2020-04-03T21:23:19.9381625Z Suite("src/test/codegen") not skipped for "bootstrap::test::Codegen" -- not in ["src/tools/tidy"]
2020-04-03T21:23:19.9566932Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-03T21:23:20.1484292Z 
2020-04-03T21:23:20.1484844Z running 183 tests
2020-04-03T21:23:22.6459250Z iiii......i............ii.i..iiii....i....i...........i............i..i..................i....i..... 100/183
2020-04-03T21:23:24.9959439Z .......i.i.i...iii..iiiiiiiiiiiiiiii.......................iii.............ii......
2020-04-03T21:23:24.9963545Z 
2020-04-03T21:23:24.9971007Z  finished in 5.040
2020-04-03T21:23:24.9981769Z Suite("src/test/codegen-units") not skipped for "bootstrap::test::CodegenUnits" -- not in ["src/tools/tidy"]
2020-04-03T21:23:25.0165685Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-03T21:23:26.9478168Z Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
2020-04-03T21:23:26.9663122Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-03T21:23:27.1163794Z 
2020-04-03T21:23:27.1164766Z running 9 tests
2020-04-03T21:23:27.1167600Z iiiiiiiii
2020-04-03T21:23:27.1170024Z 
2020-04-03T21:23:27.1173421Z  finished in 0.150
2020-04-03T21:23:27.1174356Z Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
2020-04-03T21:23:27.1359257Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-03T21:23:45.3581149Z Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
2020-04-03T21:23:45.3810398Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-03T21:23:45.5565524Z 
2020-04-03T21:23:45.5565799Z running 115 tests
2020-04-03T21:23:57.9328364Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii.........i.....i..i.......ii.i.ii.. 100/115
2020-04-03T21:23:59.5708763Z ...iiii.....ii.
2020-04-03T21:23:59.5709966Z 
2020-04-03T21:23:59.5715935Z  finished in 14.190
2020-04-03T21:23:59.5721318Z Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
2020-04-03T21:23:59.5725898Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-03T21:34:31.0973334Z ---- sync.rs - sync::Arc<T>::decr_strong_count (line 825) stdout ----
2020-04-03T21:34:31.0974116Z error[E0658]: use of unstable library feature 'arc_mutate_strong_count'
2020-04-03T21:34:31.0974835Z   --> sync.rs:833:4
2020-04-03T21:34:31.0975136Z    |
2020-04-03T21:34:31.0975443Z 11 |    Arc::decr_strong_count(ptr);
2020-04-03T21:34:31.0976097Z    |
2020-04-03T21:34:31.0976596Z    = help: add `#![feature(arc_mutate_strong_count)]` to the crate attributes to enable
2020-04-03T21:34:31.0976930Z 
2020-04-03T21:34:31.0977204Z error: aborting due to previous error
---
2020-04-03T21:34:31.1052776Z 
2020-04-03T21:34:31.1059951Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-04-03T21:34:31.1060519Z Build completed unsuccessfully in 1:11:49
2020-04-03T21:34:31.1114858Z == clock drift check ==
2020-04-03T21:34:31.1132341Z   local time: Fri Apr  3 21:34:31 UTC 2020
2020-04-03T21:34:31.2837783Z   network time: Fri, 03 Apr 2020 21:34:31 GMT
2020-04-03T21:34:31.8720342Z 
2020-04-03T21:34:31.8720342Z 
2020-04-03T21:34:31.8806193Z ##[error]Bash exited with code '1'.
2020-04-03T21:34:31.8819864Z ##[section]Finishing: Run build
2020-04-03T21:34:31.8867725Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T21:34:31.8872780Z Task         : Get sources
2020-04-03T21:34:31.8873144Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-03T21:34:31.8873482Z Version      : 1.0.0
2020-04-03T21:34:31.8873716Z Author       : Microsoft
2020-04-03T21:34:31.8873716Z Author       : Microsoft
2020-04-03T21:34:31.8874199Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-03T21:34:31.8874602Z ==============================================================================
2020-04-03T21:34:32.2091152Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-03T21:34:32.2132789Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-03T21:34:32.2220399Z Cleaning up task key
2020-04-03T21:34:32.2221688Z Start cleaning up orphan processes.
2020-04-03T21:34:32.2388753Z Terminate orphan process: pid (3633) (python)
2020-04-03T21:34:32.2535234Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@yoshuawuyts yoshuawuyts changed the title Add Arc::increment_strong_count Add Arc::incr_strong_count and Arc::decr_strong_count Apr 4, 2020
@yoshuawuyts yoshuawuyts changed the title Add Arc::incr_strong_count and Arc::decr_strong_count Add Arc::{incr,decr}_strong_count Apr 4, 2020
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 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.
2020-04-04T10:43:01.8604166Z ========================== Starting Command Output ===========================
2020-04-04T10:43:01.8606822Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/3c046e42-8f5b-4745-9a45-4415f34c7da6.sh
2020-04-04T10:43:01.8607107Z 
2020-04-04T10:43:01.8611536Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-04T10:43:01.8630237Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-04T10:43:01.8633414Z Task         : Get sources
2020-04-04T10:43:01.8633720Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-04T10:43:01.8634034Z Version      : 1.0.0
2020-04-04T10:43:01.8634237Z Author       : Microsoft
---
2020-04-04T10:43:02.8557428Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-04T10:43:02.8563395Z ##[command]git config gc.auto 0
2020-04-04T10:43:02.8568549Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-04T10:43:02.8573206Z ##[command]git config --get-all http.proxy
2020-04-04T10:43:02.8580937Z ##[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/70733/merge:refs/remotes/pull/70733/merge
---
2020-04-04T10:45:04.7760553Z Looks like docker image is the same as before, not uploading
2020-04-04T10:45:12.7937990Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-04T10:45:12.8239482Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-04T10:45:12.8269439Z == clock drift check ==
2020-04-04T10:45:12.8278250Z   local time: Sat Apr  4 10:45:12 UTC 2020
2020-04-04T10:45:12.9267160Z   network time: Sat, 04 Apr 2020 10:45:12 GMT
2020-04-04T10:45:12.9292533Z Starting sccache server...
2020-04-04T10:45:13.0131195Z configure: processing command line
2020-04-04T10:45:13.0131521Z configure: 
2020-04-04T10:45:13.0132387Z configure: rust.dist-src        := False
---
2020-04-04T10:50:02.0689591Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-04T10:50:03.4627115Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-04T10:50:04.9530311Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-04T10:50:05.5445516Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-04T10:50:14.3554257Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-04T10:50:16.1557175Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-04T10:50:20.3131156Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-04T10:50:24.1916310Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-04T10:50:33.7428973Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-04T11:11:23.5677142Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-04T11:11:25.2484963Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-04T11:11:27.1242186Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-04T11:11:28.3247141Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-04T11:11:39.0211289Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-04T11:11:41.1362207Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-04T11:11:46.1794380Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-04T11:11:51.3705886Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-04T11:12:02.3837932Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-04T11:36:11.3463682Z .................................................................................................... 1700/9875
2020-04-04T11:36:15.1340371Z .................................................................................................... 1800/9875
2020-04-04T11:36:23.6221944Z ................................................................................................i... 1900/9875
2020-04-04T11:36:31.0379258Z .................................................................................................... 2000/9875
2020-04-04T11:36:37.1043239Z ......................................................................................iiiii......... 2100/9875
2020-04-04T11:36:56.8616068Z .................................................................................................... 2300/9875
2020-04-04T11:36:58.9081533Z .................................................................................................... 2400/9875
2020-04-04T11:37:01.0049364Z .................................................................................................... 2500/9875
2020-04-04T11:37:06.6850365Z .................................................................................................... 2600/9875
---
2020-04-04T11:39:50.8111825Z ............................................................i...............i....................... 5000/9875
2020-04-04T11:39:57.8615390Z .................................................................................................... 5100/9875
2020-04-04T11:40:05.2211629Z .................................................................................................... 5200/9875
2020-04-04T11:40:10.0154258Z .....i.............................................................................................. 5300/9875
2020-04-04T11:40:19.4278243Z ..............................................................................................ii.ii. 5400/9875
2020-04-04T11:40:23.8747737Z .......i...i........................................................................................ 5500/9875
2020-04-04T11:40:32.0674385Z .......................................i............................................................ 5700/9875
2020-04-04T11:40:32.0674385Z .......................................i............................................................ 5700/9875
2020-04-04T11:40:41.1834734Z ...........................................................ii....................................i.. 5800/9875
2020-04-04T11:40:52.8892570Z .................................................................................................... 6000/9875
2020-04-04T11:40:52.8892570Z .................................................................................................... 6000/9875
2020-04-04T11:41:02.0093227Z ...........................................................................................ii...i..i 6100/9875
2020-04-04T11:41:13.4384484Z i...........i....................................................................................... 6200/9875
2020-04-04T11:41:26.2429949Z .................................................................................................... 6400/9875
2020-04-04T11:41:28.9685146Z .................................................................................................... 6500/9875
2020-04-04T11:41:28.9685146Z .................................................................................................... 6500/9875
2020-04-04T11:41:40.9998158Z .....................i..ii.......................................................................... 6600/9875
2020-04-04T11:42:01.1813798Z .................................................................................................... 6800/9875
2020-04-04T11:42:03.2401573Z .....................i.............................................................................. 6900/9875
2020-04-04T11:42:05.2890704Z .................................................................................................... 7000/9875
2020-04-04T11:42:07.4094355Z ............................................................i....................................... 7100/9875
---
2020-04-04T11:43:40.1190118Z .................................................................................................... 7800/9875
2020-04-04T11:43:44.4183555Z .................................................................................................... 7900/9875
2020-04-04T11:43:49.8317417Z .................................................................................................... 8000/9875
2020-04-04T11:43:57.1906037Z ........................i........................................................................... 8100/9875
2020-04-04T11:44:04.7761069Z .........................................................................iiiiiiiiii.i............... 8200/9875
2020-04-04T11:44:19.5330453Z .................i......i........................................................................... 8400/9875
2020-04-04T11:44:23.9556517Z .................................................................................................... 8500/9875
2020-04-04T11:44:34.4728785Z .................................................................................................... 8600/9875
2020-04-04T11:44:45.8795924Z .................................................................................................... 8700/9875
---
2020-04-04T11:47:05.8550830Z Suite("src/test/codegen") not skipped for "bootstrap::test::Codegen" -- not in ["src/tools/tidy"]
2020-04-04T11:47:05.8732552Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-04T11:47:06.0691820Z 
2020-04-04T11:47:06.0692197Z running 185 tests
2020-04-04T11:47:08.6577583Z iiii......i............ii.i..iiii....i....i...........i............i..i..................i....i..... 100/185
2020-04-04T11:47:11.2076205Z .......i.i.i...iii..iiiiiiiiiiiiiiii.......................iii...............ii......
2020-04-04T11:47:11.2083318Z 
2020-04-04T11:47:11.2083473Z  finished in 5.334
2020-04-04T11:47:11.2091498Z Suite("src/test/codegen-units") not skipped for "bootstrap::test::CodegenUnits" -- not in ["src/tools/tidy"]
2020-04-04T11:47:11.2273604Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-04T11:47:13.2270700Z Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
2020-04-04T11:47:13.2455297Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-04T11:47:13.3960540Z 
2020-04-04T11:47:13.3960958Z running 9 tests
2020-04-04T11:47:13.3962382Z iiiiiiiii
2020-04-04T11:47:13.3963593Z 
2020-04-04T11:47:13.3968082Z  finished in 0.150
2020-04-04T11:47:13.3969468Z Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
2020-04-04T11:47:13.4161258Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-04T11:47:32.2663005Z Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
2020-04-04T11:47:32.2872137Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-04T11:47:32.4596495Z 
2020-04-04T11:47:32.4596853Z running 115 tests
2020-04-04T11:47:45.1720847Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii.........i.....i..i.......ii.i.ii.. 100/115
2020-04-04T11:47:46.8259696Z ...iiii.....ii.
2020-04-04T11:47:46.8260983Z 
2020-04-04T11:47:46.8268247Z  finished in 14.539
2020-04-04T11:47:46.8274530Z Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
2020-04-04T11:47:46.8279720Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-04T11:58:16.4623318Z ....................................................................................F.........F..... 400/489
2020-04-04T11:58:26.2756379Z .........................................................................................
2020-04-04T11:58:26.2757457Z failures:
2020-04-04T11:58:26.2760074Z 
2020-04-04T11:58:26.2761471Z ---- sync.rs - sync::Arc<T>::decr_strong_count (line 826) stdout ----
2020-04-04T11:58:26.2762371Z error: expected `;`, found ``assert_eq``
2020-04-04T11:58:26.2763261Z   --> sync.rs:838:34
2020-04-04T11:58:26.2763828Z    |
2020-04-04T11:58:26.2764215Z 15 |     let five = Arc::from_raw(ptr)
2020-04-04T11:58:26.2764744Z    |                                  ^ help: add `;` here
2020-04-04T11:58:26.2765724Z ...
2020-04-04T11:58:26.2766177Z 19 |     assert_eq!(1, Arc::strong_count(&five));
2020-04-04T11:58:26.2767165Z    |     --------- unexpected token
2020-04-04T11:58:26.2768001Z error: aborting due to previous error
2020-04-04T11:58:26.2768370Z 
2020-04-04T11:58:26.2768890Z Couldn't compile the test.
2020-04-04T11:58:26.2769604Z ---- sync.rs - sync::Arc<T>::incr_strong_count (line 767) stdout ----
2020-04-04T11:58:26.2769604Z ---- sync.rs - sync::Arc<T>::incr_strong_count (line 767) stdout ----
2020-04-04T11:58:26.2770147Z error: expected `;`, found ``assert_eq``
2020-04-04T11:58:26.2770730Z   --> sync.rs:778:34
2020-04-04T11:58:26.2771084Z    |
2020-04-04T11:58:26.2771478Z 14 |     let five = Arc::from_raw(ptr)
2020-04-04T11:58:26.2771973Z    |                                  ^ help: add `;` here
2020-04-04T11:58:26.2772384Z ...
2020-04-04T11:58:26.2772797Z 18 |     assert_eq!(2, Arc::strong_count(&five));
2020-04-04T11:58:26.2773428Z    |     --------- unexpected token
2020-04-04T11:58:26.2774143Z error: aborting due to previous error
2020-04-04T11:58:26.2775001Z 
2020-04-04T11:58:26.2775624Z Couldn't compile the test.
2020-04-04T11:58:26.2775970Z 
---
2020-04-04T11:58:26.2852544Z 
2020-04-04T11:58:26.2864568Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-04-04T11:58:26.2865180Z Build completed unsuccessfully in 1:11:47
2020-04-04T11:58:26.2920243Z == clock drift check ==
2020-04-04T11:58:26.2942433Z   local time: Sat Apr  4 11:58:26 UTC 2020
2020-04-04T11:58:26.5902476Z   network time: Sat, 04 Apr 2020 11:58:26 GMT
2020-04-04T11:58:26.9765659Z 
2020-04-04T11:58:26.9765659Z 
2020-04-04T11:58:26.9833543Z ##[error]Bash exited with code '1'.
2020-04-04T11:58:26.9859639Z ##[section]Finishing: Run build
2020-04-04T11:58:26.9911241Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-04T11:58:26.9916263Z Task         : Get sources
2020-04-04T11:58:26.9916616Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-04T11:58:26.9916921Z Version      : 1.0.0
2020-04-04T11:58:26.9917135Z Author       : Microsoft
2020-04-04T11:58:26.9917135Z Author       : Microsoft
2020-04-04T11:58:26.9917492Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-04T11:58:26.9917893Z ==============================================================================
2020-04-04T11:58:27.2983959Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-04T11:58:27.3028285Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-04T11:58:27.3114984Z Cleaning up task key
2020-04-04T11:58:27.3116157Z Start cleaning up orphan processes.
2020-04-04T11:58:27.3284508Z Terminate orphan process: pid (4097) (python)
2020-04-04T11:58:27.3452410Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

@yoshuawuyts yoshuawuyts marked this pull request as ready for review April 4, 2020 16:11
src/liballoc/sync.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Matthias247 Matthias247 left a comment

Choose a reason for hiding this comment

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

The functions all seem to lead to wrong reference counts at the moment.

I highly recommend adding tests which check for the expected reference counts after invoking the functions.

I am surprised that no tests on the RawWaker are failing - are there none? I know the initial implementation I did during RawWaker stabilization had ones - but wasn't merged back then. Not sure about the test coverage of the recently added implementation. If there are none it would be good to check refcounts there too.

src/liballoc/sync.rs Outdated Show resolved Hide resolved
src/liballoc/sync.rs Outdated Show resolved Hide resolved
@Matthias247
Copy link
Contributor

I'm saying that I think the more ergonomic API is probably something like

unsafe fn increment_strong_count(ptr: *const T);
unsafe fn decrement_strong_count(ptr: *const T);

I agree that this API is more helpful for the use-case this is currently targetting. But I'm undecided whether I like it. It has not a lot of type information regarding what it targets (no &Arc<T>), and therefore it seems a bit prone to misuse. However if &Arc<T> is required the new API would be not too helpful anymore, since the user would still need to perform the also error-prone conversion steps.

@Mark-Simulacrum
Copy link
Member

@Matthias247 Note that these will always be called like Arc::incr_strong_count(ptr) (there's not really a way to not mention the Arc there beyond e.g. conversion to a function pointer or something); that makes me less worried about accepting a &Arc<T> as the first parameter.

@yoshuawuyts
Copy link
Member Author

yoshuawuyts commented Apr 5, 2020

current API

This is the API we currently have to manipulate the strong reference count with Arc. Through drop and mem::forget we're able to manipulate the reference count, but providing dedicated methods to perform this would make it more ergonomic and less prone to errors:

// Increment the strong reference count
let waker: Arc<W> = Arc::from_raw(waker as *const W);
mem::forget(Arc::clone(&waker));

// Decrement the strong reference count
mem::drop(Arc::from_raw(waker as *const W));

associated pointer API

This is the (unsafe) API @Mark-Simulacrum proposed. This takes a pointer to an Arc, and increments / decrements the strong refcount. An upside of this API is that it works well for the intended use of the API (e.g. if you're managing an Arc pointer yourself). A downside is that unlike any other methods on Arc it takes a pointer.

// Increment the strong reference count
Arc::incr_strong_count(waker as *const W);

// Decrement the strong reference count
Arc::decr_strong_count(waker as *const W);

method API

An alternative would be to provide increment/decrement methods on functions that consume an Arc instead (to prevent changing counters on drop, which as @Matthias247 pointed out earlier can be a gotcha), making the methods more consistent with the existing methods. These methods also don't need to be unsafe:

// Increment the strong reference count
let arc = Arc::from_raw(waker as *const W);
arc.incr_strong_count();

// Decrement the strong reference count
let arc = Arc::from_raw(waker as *const W);
arc.decr_strong_count();

This is closer to the design I originally proposed. But despite it being more consistent with existing methods, I think the associated pointer design is superior. The only reasonable case I can think of when counters should be manipulated manually is when manually using Arc through a pointer.

One added benefit that comes with the associated pointer API is that it allows us to make progress on documenting using Arc through a pointer. As we see in #68700 this is a legit use, and providing dedicated methods on the pointer can show how to construct and manually manage the strong reference count.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 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.
2020-04-05T14:50:46.9572827Z ========================== Starting Command Output ===========================
2020-04-05T14:50:46.9575295Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/c698e9aa-da8b-4d51-a138-236529c0d78e.sh
2020-04-05T14:50:46.9575573Z 
2020-04-05T14:50:46.9579975Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-05T14:50:46.9601081Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-05T14:50:46.9604559Z Task         : Get sources
2020-04-05T14:50:46.9604868Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-05T14:50:46.9605188Z Version      : 1.0.0
2020-04-05T14:50:46.9605391Z Author       : Microsoft
---
2020-04-05T14:50:48.2251213Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-05T14:50:48.2257044Z ##[command]git config gc.auto 0
2020-04-05T14:50:48.2260805Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-05T14:50:48.2264249Z ##[command]git config --get-all http.proxy
2020-04-05T14:50:48.2272074Z ##[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/70733/merge:refs/remotes/pull/70733/merge
---
2020-04-05T14:52:49.0570093Z Looks like docker image is the same as before, not uploading
2020-04-05T14:52:56.4217063Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-05T14:52:56.4482927Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-05T14:52:56.4508220Z == clock drift check ==
2020-04-05T14:52:56.4517765Z   local time: Sun Apr  5 14:52:56 UTC 2020
2020-04-05T14:52:56.7206104Z   network time: Sun, 05 Apr 2020 14:52:56 GMT
2020-04-05T14:52:56.7219504Z Starting sccache server...
2020-04-05T14:52:56.8052318Z configure: processing command line
2020-04-05T14:52:56.8053800Z configure: 
2020-04-05T14:52:56.8055726Z configure: rust.dist-src        := False
---
2020-04-05T14:57:49.5773236Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-05T14:57:50.9668085Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-05T14:57:52.3670940Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-05T14:57:52.4671405Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-05T14:58:01.9313930Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-05T14:58:03.5188420Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-05T14:58:07.6719920Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-05T14:58:11.5809152Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-05T14:58:20.8681801Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-05T15:19:41.6761601Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-05T15:19:43.4043645Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-05T15:19:45.3778158Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-05T15:19:46.0163461Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-05T15:19:57.4614580Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-05T15:19:59.2869822Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-05T15:20:04.4719395Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-05T15:20:09.7637264Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-05T15:20:21.5475110Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-05T15:45:01.8341245Z .................................................................................................... 1700/9876
2020-04-05T15:45:05.7975087Z .................................................................................................... 1800/9876
2020-04-05T15:45:14.5288023Z ................................................................................................i... 1900/9876
2020-04-05T15:45:22.2297601Z .................................................................................................... 2000/9876
2020-04-05T15:45:28.4833158Z ......................................................................................iiiii......... 2100/9876
2020-04-05T15:45:48.9540198Z .................................................................................................... 2300/9876
2020-04-05T15:45:51.0973627Z .................................................................................................... 2400/9876
2020-04-05T15:45:53.3152948Z .................................................................................................... 2500/9876
2020-04-05T15:45:59.1949756Z .................................................................................................... 2600/9876
---
2020-04-05T15:48:47.8291033Z ............................................................i...............i....................... 5000/9876
2020-04-05T15:48:54.9904236Z .................................................................................................... 5100/9876
2020-04-05T15:49:02.4316919Z .................................................................................................... 5200/9876
2020-04-05T15:49:07.3927483Z .....i.............................................................................................. 5300/9876
2020-04-05T15:49:17.0720238Z ..............................................................................................ii.ii. 5400/9876
2020-04-05T15:49:21.6900263Z .......i...i........................................................................................ 5500/9876
2020-04-05T15:49:30.1437079Z .......................................i............................................................ 5700/9876
2020-04-05T15:49:30.1437079Z .......................................i............................................................ 5700/9876
2020-04-05T15:49:39.5068621Z ...........................................................ii.....................................i. 5800/9876
2020-04-05T15:49:51.5507902Z .................................................................................................... 6000/9876
2020-04-05T15:49:51.5507902Z .................................................................................................... 6000/9876
2020-04-05T15:50:00.9723308Z ............................................................................................ii...i.. 6100/9876
2020-04-05T15:50:12.6102639Z ii...........i...................................................................................... 6200/9876
2020-04-05T15:50:26.0127267Z .................................................................................................... 6400/9876
2020-04-05T15:50:28.6851966Z .................................................................................................... 6500/9876
2020-04-05T15:50:28.6851966Z .................................................................................................... 6500/9876
2020-04-05T15:50:40.8334726Z ......................i..ii......................................................................... 6600/9876
2020-04-05T15:51:00.6828619Z .................................................................................................... 6800/9876
2020-04-05T15:51:02.7341343Z ......................i............................................................................. 6900/9876
2020-04-05T15:51:04.7401382Z .................................................................................................... 7000/9876
2020-04-05T15:51:06.8840401Z .............................................................i...................................... 7100/9876
---
2020-04-05T15:52:42.8580470Z .................................................................................................... 7800/9876
2020-04-05T15:52:47.1939100Z .................................................................................................... 7900/9876
2020-04-05T15:52:52.9871837Z .................................................................................................... 8000/9876
2020-04-05T15:53:00.6884242Z .........................i.......................................................................... 8100/9876
2020-04-05T15:53:08.5538301Z ..........................................................................iiiiiiiiii.i.............. 8200/9876
2020-04-05T15:53:23.7446687Z ..................i......i.......................................................................... 8400/9876
2020-04-05T15:53:28.3532494Z .................................................................................................... 8500/9876
2020-04-05T15:53:38.9576880Z .................................................................................................... 8600/9876
2020-04-05T15:53:50.7355468Z .................................................................................................... 8700/9876
---
2020-04-05T15:56:07.6838488Z Suite("src/test/codegen") not skipped for "bootstrap::test::Codegen" -- not in ["src/tools/tidy"]
2020-04-05T15:56:07.7025965Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-05T15:56:07.9002117Z 
2020-04-05T15:56:07.9002439Z running 185 tests
2020-04-05T15:56:10.5335348Z iiii......i............ii.i..iiii....i....i...........i............i..i..................i....i..... 100/185
2020-04-05T15:56:13.0559586Z .......i.i.i...iii..iiiiiiiiiiiiiiii.......................iii...............ii......
2020-04-05T15:56:13.0570696Z 
2020-04-05T15:56:13.0574334Z  finished in 5.352
2020-04-05T15:56:13.0577147Z Suite("src/test/codegen-units") not skipped for "bootstrap::test::CodegenUnits" -- not in ["src/tools/tidy"]
2020-04-05T15:56:13.0761316Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-05T15:56:15.0890194Z Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
2020-04-05T15:56:15.1083690Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-05T15:56:15.2607159Z 
2020-04-05T15:56:15.2608124Z running 9 tests
2020-04-05T15:56:15.2609557Z iiiiiiiii
2020-04-05T15:56:15.2612500Z 
2020-04-05T15:56:15.2613728Z  finished in 0.153
2020-04-05T15:56:15.2617692Z Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
2020-04-05T15:56:15.2807436Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-05T15:56:34.4240262Z Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
2020-04-05T15:56:34.4466460Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-05T15:56:34.6319569Z 
2020-04-05T15:56:34.6319964Z running 115 tests
2020-04-05T15:56:48.4030972Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii.........i.....i..i.......ii.i.ii.. 100/115
2020-04-05T15:56:50.1349757Z ...iiii.....ii.
2020-04-05T15:56:50.1351030Z 
2020-04-05T15:56:50.1357041Z  finished in 15.689
2020-04-05T15:56:50.1361978Z Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
2020-04-05T15:56:50.1365394Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-05T16:07:42.5868570Z ---- sync.rs - sync::Arc<T>::decr_strong_count (line 799) stdout ----
2020-04-05T16:07:42.5869188Z error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2020-04-05T16:07:42.5869827Z   --> sync.rs:807:1
2020-04-05T16:07:42.5870123Z    |
2020-04-05T16:07:42.5870423Z 11 | Arc::decr_strong_count(ptr);
2020-04-05T16:07:42.5870872Z    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
2020-04-05T16:07:42.5871853Z    = note: consult the function's documentation for information on how to avoid undefined behavior
2020-04-05T16:07:42.5872261Z 
2020-04-05T16:07:42.5872662Z error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2020-04-05T16:07:42.5873253Z   --> sync.rs:811:12
2020-04-05T16:07:42.5873253Z   --> sync.rs:811:12
2020-04-05T16:07:42.5873563Z    |
2020-04-05T16:07:42.5873865Z 15 | let five = Arc::from_raw(ptr);
2020-04-05T16:07:42.5874261Z    |            ^^^^^^^^^^^^^^^^^^ call to unsafe function
2020-04-05T16:07:42.5875243Z    = note: consult the function's documentation for information on how to avoid undefined behavior
2020-04-05T16:07:42.5875636Z 
2020-04-05T16:07:42.5875952Z error: aborting due to 2 previous errors
2020-04-05T16:07:42.5876227Z 
2020-04-05T16:07:42.5876227Z 
2020-04-05T16:07:42.5876779Z For more information about this error, try `rustc --explain E0133`.
2020-04-05T16:07:42.5877654Z Couldn't compile the test.
2020-04-05T16:07:42.5878307Z ---- sync.rs - sync::Arc<T>::incr_strong_count (line 765) stdout ----
2020-04-05T16:07:42.5878849Z error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2020-04-05T16:07:42.5879428Z   --> sync.rs:773:1
2020-04-05T16:07:42.5879733Z    |
2020-04-05T16:07:42.5880419Z 11 | Arc::incr_strong_count(ptr);
2020-04-05T16:07:42.5881193Z    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
2020-04-05T16:07:42.5882313Z    = note: consult the function's documentation for information on how to avoid undefined behavior
2020-04-05T16:07:42.5882701Z 
2020-04-05T16:07:42.5883411Z error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2020-04-05T16:07:42.5883959Z   --> sync.rs:777:12
2020-04-05T16:07:42.5883959Z   --> sync.rs:777:12
2020-04-05T16:07:42.5884236Z    |
2020-04-05T16:07:42.5884533Z 15 | let five = Arc::from_raw(ptr);
2020-04-05T16:07:42.5884941Z    |            ^^^^^^^^^^^^^^^^^^ call to unsafe function
2020-04-05T16:07:42.5885762Z    = note: consult the function's documentation for information on how to avoid undefined behavior
2020-04-05T16:07:42.5886142Z 
2020-04-05T16:07:42.5886558Z error: aborting due to 2 previous errors
2020-04-05T16:07:42.5886730Z 
---
2020-04-05T16:07:42.5965590Z 
2020-04-05T16:07:43.2320922Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-04-05T16:07:43.2327391Z Build completed unsuccessfully in 1:13:19
2020-04-05T16:07:43.2358572Z == clock drift check ==
2020-04-05T16:07:43.2359011Z   local time: Sun Apr  5 16:07:42 UTC 2020
2020-04-05T16:07:43.2359439Z   network time: Sun, 05 Apr 2020 16:07:42 GMT
2020-04-05T16:07:43.2359987Z 
2020-04-05T16:07:43.2359987Z 
2020-04-05T16:07:43.2392595Z ##[error]Bash exited with code '1'.
2020-04-05T16:07:43.2409877Z ##[section]Finishing: Run build
2020-04-05T16:07:43.2455423Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-05T16:07:43.2460352Z Task         : Get sources
2020-04-05T16:07:43.2460714Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-05T16:07:43.2461028Z Version      : 1.0.0
2020-04-05T16:07:43.2461249Z Author       : Microsoft
2020-04-05T16:07:43.2461249Z Author       : Microsoft
2020-04-05T16:07:43.2461617Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-05T16:07:43.2462025Z ==============================================================================
2020-04-05T16:07:43.5712779Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-05T16:07:43.5717146Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70733/merge to s
2020-04-05T16:07:43.5800636Z Cleaning up task key
2020-04-05T16:07:43.5801868Z Start cleaning up orphan processes.
2020-04-05T16:07:43.5972216Z Terminate orphan process: pid (5346) (python)
2020-04-05T16:07:43.6203651Z ##[section]Finishing: Finalize Job

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 @rust-lang/infra. (Feature Requests)

src/liballoc/sync.rs Outdated Show resolved Hide resolved
@Matthias247
Copy link
Contributor

method API

An alternative would be to provide increment/decrement methods on functions that consume an Arc instead

That one won't really help, because the challenging part seems to be getting an Arc from the raw pointer while not messing up the refcounts. This again places the burden on the user to get it right.

I think the most misuse resistant API seems to be the one that @Mark-Simulacrum proposed.

Given this discussion, I'm however not convinced that something like this should be added at all. It's kind of a hack, to make certain use-cases work without requiring to also write a custom Arc type. The amount of use-cases is low, and users need to be experts anyway, since this is about implementing your own custom ownership management. I'm not sure if it's in the interest of std to add functionality for it, as long as the method can also expressed in other ways. I'm also not aware of any other shared_ptr API which exposes that functionality.

@yoshuawuyts
Copy link
Member Author

yoshuawuyts commented Apr 5, 2020

It's kind of a hack, to make certain use-cases work without requiring to also write a custom Arc type. The amount of use-cases is low, and users need to be experts anyway [...]

@Matthias247 This issue was motivated by the use in #68700 (comment). And as @stjepang pointed out in #70733 (comment) even Rust experts regularly get this wrong.

I agree this is not an API that's likely to be used by people new to Rust. But using Arc to construct a custom reference-counted structure is a legit use case, and one I think should be encouraged. Writing a custom reference counter using atomics is even harder to get right, increasing the likelihood bugs and vulnerabilities might occur. If we can make it easier for Arc to be used for custom reference counters I think that'd be a net gain.

@Mark-Simulacrum
Copy link
Member

The methods seem to be fine, but I believe are needlessly noisy; when using this API you essentially always already have the raw pointer and nothing else. I'm not sure I follow when you say that the Arc-taking methods are misusable, since I think they're guaranteed to work (and indeed both would even be safe, though Arc::from_raw would be unsafe of course).

I agree, though, that I believe the raw pointer taking methods are the best choice here, as I think they're easiest to understand.

I pretty strongly disagree that std shouldn't provide them, though. I don't really see how it's a hack, rather it seems like a natural thing to want in unsafe code interacting with shared ownership (using Arc). Its also something that we know is being used - so providing a canonical way of doing so seems good.

@Mark-Simulacrum
Copy link
Member

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented May 7, 2020

📌 Commit b04599f has been approved by Mark-Simulacrum

@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 May 7, 2020
@bors
Copy link
Contributor

bors commented May 7, 2020

⌛ Testing commit b04599f with merge 86487ffa5824c4c3e89363d8b095199bf876f166...

@Dylan-DPC-zz
Copy link

@bors retry yield

@bors
Copy link
Contributor

bors commented May 7, 2020

⌛ Testing commit b04599f with merge 59a0fec547f3fc3832f4b1f6b1637c7718279c13...

@bors
Copy link
Contributor

bors commented May 7, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 7, 2020
@Dylan-DPC-zz
Copy link

@bors retry (included in rollup so yielding)

@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-review Status: Awaiting review from the assignee but also interested parties. labels May 7, 2020
@bors
Copy link
Contributor

bors commented May 7, 2020

⌛ Testing commit b04599f with merge a04e20496a7c19dfe64923e069e7de8c8da8f22e...

@bors
Copy link
Contributor

bors commented May 7, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 7, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request May 8, 2020
Rollup of 5 pull requests

Successful merges:

 - rust-lang#70733 (Add Arc::{incr,decr}_strong_count)
 - rust-lang#71598 (improve Drop documentation)
 - rust-lang#71783 (Detect errors caused by `async` block in 2015 edition)
 - rust-lang#71903 (reword "possible candidate" import suggestion)
 - rust-lang#71960 (Fix E0284 to not use incorrect wording)

Failed merges:

r? @ghost
@bors bors merged commit 5e9b372 into rust-lang:master May 8, 2020
@yoshuawuyts yoshuawuyts deleted the arc-increment-refcount branch May 8, 2020 10:54
@ghost ghost mentioned this pull request Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants