Created
May 29, 2014 16:17
-
-
Save XMPPwocky/81cf0033a44299ed288b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[wocky@XMPPwocky rustcrap]$ rustc -g -L . -o libplugin.so plugin.rs; rustc main.rs -L . -g -C prefer-dynamic | |
[wocky@XMPPwocky rustcrap]$ ./main | |
Got: 1024 | |
Segmentation fault (core dumped) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Core was generated by `./main'. | |
Program terminated with signal SIGSEGV, Segmentation fault. | |
#0 0x00007fee8943a140 in ?? () | |
(gdb) bt | |
#0 0x00007fee8943a140 in ?? () | |
#1 0x00007fee8a96f278 in task::spawn_opts::closure.7804 () from /home/wocky/rustcrap/../../../usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libnative-1fb5e2c0-0.11.0-pre.so | |
#2 0x00007fee8a437543 in rt::task::Task::run::closure.25317 () from /home/wocky/rustcrap/../../../usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-59beb4f7-0.11.0-pre.so | |
#3 0x00007fee8a49ca1c in rust_try () from /home/wocky/rustcrap/../../../usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-59beb4f7-0.11.0-pre.so | |
#4 0x00007fee8a4374af in rt::task::Task::run::hbc4d0611fe89bbd5rkw::v0.11.0.pre () from /home/wocky/rustcrap/../../../usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-59beb4f7-0.11.0-pre.so | |
#5 0x00007fee8a96f0e0 in task::spawn_opts::closure.7777 () from /home/wocky/rustcrap/../../../usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libnative-1fb5e2c0-0.11.0-pre.so | |
#6 0x00007fee8a43b574 in rt::thread::thread_start::h6df36152f3dd6decZ3w::v0.11.0.pre () from /home/wocky/rustcrap/../../../usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-59beb4f7-0.11.0-pre.so | |
#7 0x00007fee89968124 in start_thread () from /usr/lib/libpthread.so.0 | |
#8 0x00007fee89c684bd in clone () from /usr/lib/libc.so.6 | |
(gdb) info reg | |
rax 0x7fee8943a140 140662481854784 | |
rbx 0x0 0 | |
rcx 0x1 1 | |
rdx 0x7fee88bfede8 140662473223656 | |
rsi 0x7fee88bfede8 140662473223656 | |
rdi 0x0 0 | |
rbp 0x0 0x0 | |
rsp 0x7fee88bfed38 0x7fee88bfed38 | |
r8 0x7fee88bff700 140662473225984 | |
r9 0x7fee88bff700 140662473225984 | |
r10 0x7fee88bfecb0 140662473223344 | |
r11 0x7fee89bb2bc0 140662489689024 | |
r12 0x7fee88c1b040 140662473338944 | |
r13 0x7fee88bff700 140662473225984 | |
r14 0x7fffc7f050c0 140736547803328 | |
r15 0x7fffc7f050c0 140736547803328 | |
rip 0x7fee8943a140 0x7fee8943a140 | |
eflags 0x10246 [ PF ZF IF RF ] | |
cs 0x33 51 | |
ss 0x2b 43 | |
ds 0x0 0 | |
es 0x0 0 | |
fs 0x0 0 | |
gs 0x0 0 | |
(gdb) frame 1 | |
(gdb) disassemble | |
Dump of assembler code for function _ZN4task10spawn_opts12closure.7804E: | |
0x00007fee8a96f230 <+0>: cmp %fs:0x70,%rsp | |
0x00007fee8a96f239 <+9>: ja 0x7fee8a96f255 <_ZN4task10spawn_opts12closure.7804E+37> | |
0x00007fee8a96f23b <+11>: movabs $0x68,%r10 | |
0x00007fee8a96f245 <+21>: movabs $0x0,%r11 | |
0x00007fee8a96f24f <+31>: callq 0x7fee8a96fac8 <__morestack> | |
0x00007fee8a96f254 <+36>: retq | |
0x00007fee8a96f255 <+37>: push %r14 | |
0x00007fee8a96f257 <+39>: push %rbx | |
0x00007fee8a96f258 <+40>: sub $0x58,%rsp | |
0x00007fee8a96f25c <+44>: mov 0x20(%rdi),%rax | |
0x00007fee8a96f260 <+48>: mov 0x10(%rax),%rbx | |
0x00007fee8a96f264 <+52>: movzbl (%rax),%ecx | |
0x00007fee8a96f267 <+55>: movb $0x0,(%rax) | |
0x00007fee8a96f26a <+58>: cmp $0x1,%ecx | |
0x00007fee8a96f26d <+61>: jne 0x7fee8a96f2a0 <_ZN4task10spawn_opts12closure.7804E+112> | |
0x00007fee8a96f26f <+63>: mov 0x8(%rax),%rax | |
0x00007fee8a96f273 <+67>: mov %rbx,%rdi | |
0x00007fee8a96f276 <+70>: callq *%rax | |
=> 0x00007fee8a96f278 <+72>: test %rbx,%rbx | |
0x00007fee8a96f27b <+75>: je 0x7fee8a96f298 <_ZN4task10spawn_opts12closure.7804E+104> | |
[wocky@XMPPwocky rustcrap]$ rustc -v | |
rustc 0.11.0-pre-nightly (a183829 2014-05-28 01:06:45 -0700) | |
host: x86_64-unknown-linux-gnu | |
[wocky@XMPPwocky rustcrap]$ uname -a | |
Linux XMPPwocky 3.14.1-1-ARCH #1 SMP PREEMPT Mon Apr 14 20:40:47 CEST 2014 x86_64 GNU/Linux | |
[wocky@XMPPwocky rustcrap]$ # i don't even know |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::unstable::dynamic_lib::DynamicLibrary; | |
type RegistrarFn = fn() -> Receiver<int>; | |
fn main() { | |
let plugin = DynamicLibrary::open(Some("/home/wocky/rustcrap/libplugin.so")).unwrap(); | |
let registrar: RegistrarFn = unsafe { | |
plugin.symbol("register_plugin") | |
}.unwrap(); | |
let chan = registrar(); | |
println!("Got: {}", chan.recv()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
![crate_type = "dylib"] | |
#[no_mangle] | |
pub fn register_plugin() -> Receiver<int> { | |
spawn(proc() { | |
println!("hi"); | |
}); | |
let (tx, rx) = channel(); | |
tx.send(1024); | |
rx | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment