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

Segfault with let _x = "test" as &Any #14366

Closed
lilyball opened this issue May 22, 2014 · 7 comments · Fixed by #17721
Closed

Segfault with let _x = "test" as &Any #14366

lilyball opened this issue May 22, 2014 · 7 comments · Fixed by #17721
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@lilyball
Copy link
Contributor

The following program segfaults when run (it compiles just fine):

fn main() {
    let _x = "test" as &::std::any::Any;
}

Reproduced with rustc 0.11.0-pre (22e2204 2014-05-21 23:31:27 -0700).

@lilyball
Copy link
Contributor Author

LLDB says EXC_BAD_ACCESS (code=1, address=0xffffffffffffff9b).

@jfager
Copy link
Contributor

jfager commented Jul 24, 2014

This works for me today, are you still seeing the problem?

@nathantypanski
Copy link
Contributor

@jfager

scratch$ rustc segf.rs 
scratch$ ./segf
zsh: segmentation fault  ./segf
scratch$ rustc -v
rustc 0.12.0-pre (b3a732a3e 2014-07-23 19:56:15 +0000)

@jfager
Copy link
Contributor

jfager commented Jul 24, 2014

Hmm.

scratch$ rustc r14366.rs 
scratch$ ./r14366 
scratch$ rustc -v
rustc 0.12.0-pre-nightly (217f1fbfc 2014-07-22 23:11:12 +0000)

Maybe platform-specific? I'm on a mac, 10.9.

@lilyball
Copy link
Contributor Author

On May 22nd I was obviously seeing it (on a Mac), as I authored this, but I too cannot reproduce today.

rustc 0.12.0-pre (9cc39a054d485e46f7b8292cea690407932232ce 2014-07-21 16:51:37 +0000)

@nathantypanski
Copy link
Contributor

I'm on Linux:

$ uname -a
Linux dionysus 3.15.5-2-ARCH #1 SMP PREEMPT Fri Jul 11 07:56:02 CEST 2014 x86_64 GNU/Linux

Interesting bit: compiling this with debug symbols -> no crash:

scratch$ rustc 14366.rs
scratch$ ./14366
zsh: segmentation fault  ./14366
scratch$ rustc -g 14366.rs
scratch$ ./14366

The best I can convince lldb to tell me is this:

* thread #1: tid = 23259, 0x00007ff4c1e90dc0, name = '14366', stop reason = trace
    frame #0: 0x00007ff4c1e90dc0
-> 0x7ff4c1e90dc0:  movq   %rsp, %rdi
   0x7ff4c1e90dc3:  callq  0x7ff4c1e94ab0
   0x7ff4c1e90dc8:  movq   %rax, %r12
   0x7ff4c1e90dcb:  movl   0x21ffa7(%rip), %eax
Process 23259 stopped
* thread #1: tid = 23259, 0x0000000000000004, name = '14366', stop reason = invalid address (fault address: 0x4)
    frame #0: 0x0000000000000004
error: Input/output error

@ghost
Copy link

ghost commented Oct 1, 2014

This correctly fails to compile now:

<anon>:2:14: 2:40 error: the trait `core::kinds::Sized` is not implemented for the type `str`
<anon>:2     let _x = "test" as &::std::any::Any;
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:2:14: 2:40 note: the trait `core::kinds::Sized` must be implemented for the cast to the object type `core::any::Any`
<anon>:2     let _x = "test" as &::std::any::Any;
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:2:14: 2:40 error: the trait `core::kinds::Sized` is not implemented for the type `str`
<anon>:2     let _x = "test" as &::std::any::Any;
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:2:14: 2:40 note: the trait `core::kinds::Sized` must be implemented for the cast to the object type `core::any::Any`
<anon>:2     let _x = "test" as &::std::any::Any;
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~

(though the repeated diagnostic is undesirable)

And the correct version works:

fn main() {
    let _x = "test" as &::std::any::Any;
}

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 1, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 5, 2023
feat: Pop a notification prompting the user to add a Cargo.toml of unlinked file to the linkedProjects

cc rust-lang/rust-analyzer#13226 rust-lang/rust-analyzer#9661
lnicola pushed a commit to lnicola/rust that referenced this issue Jun 23, 2024
Currently, rust-analyzer highlights the entire region when a `cfg` is
inactive (e.g. `#[cfg(windows)]` on a Linux machine). However,
unlinked files only highlight the first three characters of the file.

This was introduced in rust-lang#8444, but users have repeatedly found
themselves with no rust-analyzer support for a file and unsure
why (see e.g. rust-lang#13226 and the intentionally prominent pop-up added in
PR rust-lang#14366).

(Anecdotally, we see this issue bite our users regularly, particularly
people new to Rust.)

Instead, highlight the entire inactive file, but mark it as all as
unused. This allows users to hover and run the quickfix from any line.

Whilst this is marginally more prominent, it's less invasive than a
pop-up, and users do want to know why they're getting no rust-analyzer
support in certain files.
lnicola pushed a commit to lnicola/rust that referenced this issue Jun 23, 2024
…eykril

fix: Highlight unlinked files consistently with inactive files

Currently, rust-analyzer highlights the entire region when a `cfg` is inactive (e.g. `#[cfg(windows)]` on a Linux machine). However, unlinked files only highlight the first three characters of the file.

This was introduced in rust-lang#8444, but users have repeatedly found themselves with no rust-analyzer support for a file and unsure why (see e.g. rust-lang#13226 and the intentionally prominent pop-up added in PR rust-lang#14366).

(Anecdotally, we see this issue bite our users regularly, particularly people new to Rust.)

Instead, highlight the entire inactive file, but mark it as all as unused. This allows users to hover and run the quickfix from any line.

Whilst this is marginally more prominent, it's less invasive than a pop-up, and users do want to know why they're getting no rust-analyzer support in certain files.

Before (note the subtle grey underline is only at the beginning of the first line):

![Screenshot 2024-06-05 at 5 41 17 PM](https://github.com/rust-lang/rust-analyzer/assets/70800/96f5d778-612e-4838-876d-35d9647fe2aa)

After (user can hover and fix from any line):

![Screenshot 2024-06-05 at 5 42 13 PM](https://github.com/rust-lang/rust-analyzer/assets/70800/6af90b79-018c-42b9-b3c5-f497de2ccbff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@lilyball @jfager @alexcrichton @nathantypanski and others