Skip to content

Fix link error with #[thread_local] introduced by #71192 - #73065

Merged
bors merged 3 commits into
rust-lang:masterfrom
Amanieu:tls-fix
Jun 18, 2020
Merged

Fix link error with #[thread_local] introduced by #71192#73065
bors merged 3 commits into
rust-lang:masterfrom
Amanieu:tls-fix

Conversation

@Amanieu

Copy link
Copy Markdown
Member

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 6, 2020
@oli-obkoli-obk added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jun 6, 2020
@oli-obk

Copy link
Copy Markdown
Contributor

@bors r+

Nominating for beta backport because the bug carried over to beta and while I'm not sure if it's exploitable without feature gates, I'd rather not take the risk.

@bors

bors commented Jun 6, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit e9b67d2 has been approved by oli-obk

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 6, 2020
@jonas-schievinkjonas-schievink added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 8, 2020
@RalfJung

Copy link
Copy Markdown
Member

So what was the problem here? Did some component "forget" to look into usize to check for things to link against? The fix doesn't have anything to do with usize though so I must be missing something.

@oli-obk

Copy link
Copy Markdown
Contributor

@bors r-

I just noticed that the regression test also passes on nightly, so it's not really testing the problem being fixed here.

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

Copy link
Copy Markdown
MemberAuthor

It still fails on the latest nightly for me. Make sure you're compiling with optimizations enabled and with multiple codegen units.

@oli-obk

Copy link
Copy Markdown
Contributor

Since the test neither specifies optimizations nor CGU, it won't test this in CI. Just turning on optimizations in the playground doesn't work: https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=95fdf2822783b106f65757321e6ce187

Can you add your command line flags to the test via a // compile-flags: foo comment?

@Amanieu

Copy link
Copy Markdown
MemberAuthor

I can reproduce the error with just rustc tls.rs -O.

@oli-obk

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jun 11, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 2af53e9 has been approved by oli-obk

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

Copy link
Copy Markdown
Contributor

So what was the problem here? Did some component "forget" to look into usize to check for things to link against? The fix doesn't have anything to do with usize though so I must be missing something.

usize is a red herring here. Casting to raw pointers would have sufficed. The cast is only there to work around the borrow checker and being able to compare addresses. If you were wondering whether the bug is because of a usize constant not being looked into, that's not a problem anymore as we don't support references to tls in const eval anymore.

The thing causing a bug here was simply that we didn't collect the DefId of the tls anymore, which randomly works in the tests we've had up to here, but was broken likely in cross crate and multi-cgu scenarios.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jun 13, 2020
@tmiasko

Copy link
Copy Markdown
Contributor
Failed in rollup #73299, on wasm32-unknown-unknown target without threads.
---- [ui] ui/tls.rs stdout ----
error: test run failed!
status: exit code: 101
command: "/node-v9.2.0-linux-x64/bin/node" "/checkout/src/etc/wasm32-shim.js" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/tls/a.wasm"
stdout:
------------------------------------------
------------------------------------------
stderr:
------------------------------------------
RuntimeError: unreachable
at __rust_start_panic (wasm-function[89]:1)
at rust_panic (wasm-function[83]:39)
at _ZN3std9panicking20rust_panic_with_hook17h4caac20c72d75dc1E (wasm-function[78]:279)
at rust_begin_unwind (wasm-function[77]:90)
at _ZN4core9panicking9panic_fmt17h2a7f8c32bf7391a0E (wasm-function[108]:58)
at _ZN4core6option18expect_none_failed17h300c1b4bc80874faE (wasm-function[118]:139)
at _ZN3std6thread5spawn17hd38fc9ede2951672E (wasm-function[4]:407)
at _ZN3tls4main17hfb802c933ee14077E (wasm-function[8]:25)
at _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h7dab73fdfb41bcd3E (wasm-function[10]:25)
at _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17hee2c79df7781245bE (wasm-function[67]:8)
at _ZN3std2rt19lang_start_internal17h5bcb99e6d909e866E (wasm-function[84]:229)
at main (wasm-function[9]:46)
at Object.<anonymous> (/checkout/src/etc/wasm32-shim.js:20:20)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
at Function.Module.runMain (module.js:682:10)
at startup (bootstrap_node.js:191:16)
------------------------------------------

Maybe build-pass would be sufficient to detect link error.

RalfJung added a commit to RalfJung/rust that referenced this pull request Jun 13, 2020
@RalfJungRalfJung mentioned this pull request Jun 13, 2020
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 16, 2020
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 16, 2020
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 16, 2020
@spastorino

spastorino commented Jun 17, 2020

Copy link
Copy Markdown
Member

This one is beta nominated so bumping the priority ...

@bors p=1

@bors

bors commented Jun 17, 2020

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 01e29c7 with merge 5cbaf60ed01b7b1e19b34b258adfce40d8924827...

@bors

bors commented Jun 17, 2020

Copy link
Copy Markdown
Collaborator

💔 Test failed - checks-azure

@borsbors 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 Jun 17, 2020
@mati865

Copy link
Copy Markdown
Member

Spurious failure:

##[error]We stopped hearing from agent Azure Pipelines 4. Verify the agent machine is running and has a healthy network connection. Anything that terminates an agent process, starves it for CPU, or blocks its network access can cause this error. For more information, see: https://go.microsoft.com/fwlink/?linkid=846610

@Amanieu

Copy link
Copy Markdown
MemberAuthor

@bors retry

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 17, 2020
@bors

bors commented Jun 18, 2020

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 01e29c7 with merge 7d16c1d...

@bors

bors commented Jun 18, 2020

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-azure
Approved by: oli-obk
Pushing 7d16c1d to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Jun 18, 2020
@bors
bors merged commit 7d16c1d into rust-lang:masterJun 18, 2020
@pnkfelix

Copy link
Copy Markdown
Contributor

Discussed in T-compiler meeting; beta approved.

@pnkfelixpnkfelix added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Jun 18, 2020
@Mark-SimulacrumMark-Simulacrum removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jun 26, 2020
@Mark-SimulacrumMark-Simulacrum mentioned this pull request Jun 26, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 27, 2020
…ulacrum
[beta] backports
This PR backports the following:
* Make novel structural match violations not a `bug` rust-lang#73446
* linker: Never pass `-no-pie` to non-gnu linkers rust-lang#73384
* Disable the `SimplifyArmIdentity` pass rust-lang#73262
* Allow inference regions when relating consts rust-lang#73225
* Fix link error with #[thread_local] introduced by rust-lang#71192rust-lang#73065
* Ensure stack when building MIR for matches rust-lang#72941
* Don't create impl candidates when obligation contains errors rust-lang#73005
r? @ghost
@cuvipercuviper added this to the 1.46 milestone May 2, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-acceptedAccepted for backporting to the compiler in the beta channel.merged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

12 participants

@Amanieu@oli-obk@bors@RalfJung@tmiasko@spastorino@mati865@pnkfelix@cuviper@jonas-schievink@Mark-Simulacrum@rust-highfive