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

#[plugin_registrar] is not type-checked #14841

Closed
kimhyunkang opened this issue Jun 12, 2014 · 6 comments
Closed

#[plugin_registrar] is not type-checked #14841

kimhyunkang opened this issue Jun 12, 2014 · 6 comments
Labels
C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@kimhyunkang
Copy link

kimhyunkang commented Jun 12, 2014

#[plugin_registrar] functions are not type-checked, which exposes unsafe memory content to the plugin modules. Nor are they checked for being pub.

I could reproduce this on the latest nightly build for x64 linux. Minimal reproducing example follows.

plugin_lib.rs :

#![crate_id = "plugin_lib"]
#![crate_type = "dylib"]

#![feature(plugin_registrar)]

#[plugin_registrar]
pub fn plugin_registrar(f: || -> ()) {
    f()
}

plugin_test.rs :

#![feature(phase)]

#[phase(plugin)]
extern crate plugin_lib;

fn main() {
    ()
}

compilation:

kimhyunkang@kanie:~/project/segfault_test$ rustc --version
rustc 0.11.0-pre-nightly (4fdc27e 2014-06-10 23:37:06 -0700)
host: x86_64-unknown-linux-gnu
kimhyunkang@kanie:~/project/segfault_test$ rustc plugin_lib.rs
kimhyunkang@kanie:~/project/segfault_test$ rustc plugin_test.rs -L .
Segmentation fault (core dumped)
@kmcallister
Copy link
Contributor

Working on this.

kmcallister added a commit to kmcallister/rust that referenced this issue Sep 15, 2014
@kmcallister
Copy link
Contributor

My fix above is gross; let's do #17833 instead.

@steveklabnik
Copy link
Member

Updated code to reproduce:

// plugin_lib.rs
#![feature(plugin_registrar)]

#[plugin_registrar]
pub fn plugin_registrar(f: fn() -> ()) {
    f()
}

and

// plugin_test.rs
#![feature(plugin)]
#![plugin(plugin_lib)]

fn main() {
    ()
}

testing:

$ rustc plugin_lib.rs --crate-type=dylib
$ rustc plugin_test.rs -L .
Segmentation fault
$ rustc --version
rustc 1.7.0-nightly (2370d461a 2015-12-30)

@Mark-Simulacrum
Copy link
Member

With rustc 1.18.0-nightly (bbdaad0dc 2017-04-14), I no longer get a segmentation fault with the code in @steveklabnik's post above. Presumably fixed, closing.

@Mark-Simulacrum
Copy link
Member

Actually, I think that was a problem with my shell, presumably... I'm not sure it segfaults, but it doesn't successfully compile plugin_test.rs, exits with exit code 1, and no error message.

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 21, 2017
@steveklabnik
Copy link
Member

When this issue was opened, we weren't sure what the system for extending rust may be. Plugins are never going to be shown to end-users, and so I don't believe this is ever going to be fixed. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

5 participants