Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Jun 18, 2020

Conversation

Amanieu
Copy link
Member

@Amanieu Amanieu commented Jun 6, 2020

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

oli-obk commented Jun 6, 2020

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

bors commented Jun 6, 2020

📌 Commit e9b67d2 has been approved by oli-obk

@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 Jun 6, 2020
@jonas-schievink jonas-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
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
Contributor

oli-obk commented Jun 10, 2020

@bors r-

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

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

Amanieu commented Jun 10, 2020

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
Contributor

oli-obk commented Jun 10, 2020

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

Amanieu commented Jun 10, 2020

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

@oli-obk
Copy link
Contributor

oli-obk commented Jun 11, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jun 11, 2020

📌 Commit 2af53e9 has been approved by oli-obk

@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 Jun 11, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Jun 12, 2020

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
Fix link error with #[thread_local] introduced by rust-lang#71192

r? @oli-obk
@tmiasko
Copy link
Contributor

tmiasko commented Jun 13, 2020

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
Fix link error with #[thread_local] introduced by rust-lang#71192

r? @oli-obk
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 16, 2020
Fix link error with #[thread_local] introduced by rust-lang#71192

r? @oli-obk
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 16, 2020
Fix link error with #[thread_local] introduced by rust-lang#71192

r? @oli-obk
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 16, 2020
Fix link error with #[thread_local] introduced by rust-lang#71192

r? @oli-obk
@spastorino
Copy link
Member

spastorino commented Jun 17, 2020

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

@bors p=1

@bors
Copy link
Contributor

bors commented Jun 17, 2020

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

@bors
Copy link
Contributor

bors commented Jun 17, 2020

💔 Test failed - checks-azure

@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 Jun 17, 2020
@mati865
Copy link
Contributor

mati865 commented Jun 17, 2020

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

Amanieu commented Jun 17, 2020

@bors retry

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

bors commented Jun 18, 2020

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

@bors
Copy link
Contributor

bors commented Jun 18, 2020

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

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

Discussed in T-compiler meeting; beta approved.

@pnkfelix pnkfelix added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Jun 18, 2020
@Mark-Simulacrum Mark-Simulacrum removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label 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#71192 rust-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
@cuviper cuviper added this to the 1.46 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant 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.