bytecodealliance / cranelift-jit-demo

JIT compiler and runtime for a toy language, using Cranelift
Apache License 2.0
649 stars 61 forks source link

Jit demo does "PermissionDenied" #54

Closed adsick closed 2 years ago

adsick commented 3 years ago

my OS: Fedora 33, Rust: 1.49.0

so when I do cargo run in "cranelift-jit-demo-main" it compiles but then:

thread 'main' panicked at 'unable to make memory readable+executable: SystemCall(Os { code: 13, kind: PermissionDenied, message: "Permission denied" })', /home/adsick/.cargo/registry/src/github.com-1ecc6299db9ec823/cranelift-simplejit-0.68.0/src/memory.rs:197:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

why is it so and how do I fix it (or rather it should be fixed somewhere in the actual project, I dunno)

bjorn3 commented 3 years ago

SELinux is enabled by default on Fedora, which disallows marking part of the heap as executable. Try enabling the selinux-fix feature of cranelift-jit in Cargo.toml, which causes mmap to be used instead. See https://github.com/bytecodealliance/cranelift/issues/772.

adsick commented 3 years ago

how to "enabling the selinux-fix feature of cranelift-jit in Cargo.toml"

bjorn3 commented 3 years ago

Replace this line https://github.com/bytecodealliance/cranelift-jit-demo/blob/e120e20ebf410597b6973551229fec029506192e/Cargo.toml#L13 with cranelift-simplejit = { version = "0.68.0", features = ["selinux-fix"] }.

adsick commented 3 years ago

finally worked, thanks you, dude. mb add it as a comment in Cargo.toml so others will see and uncomment this piece in case they get in the same problem?