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

Linear IR broke llvmcall(something(...), ...) #25041

Closed
maleadt opened this issue Dec 12, 2017 · 3 comments
Closed

Linear IR broke llvmcall(something(...), ...) #25041

maleadt opened this issue Dec 12, 2017 · 3 comments
Assignees
Labels
regression Regression in behavior compared to a previous version

Comments

@maleadt
Copy link
Member

maleadt commented Dec 12, 2017

Not sure whether this is now unsupported, or a bug. Repro:

ptr = Ptr{Void}(1)
x() = Base.llvmcall(identity(ptr), Void, Tuple{})
x()

Obviously this should crash anyhow, but it does so because the ir argument to llvmcall is null, making the check for jl_is_tuple crash:

(gdb) break emit_llvmcall
Function "emit_llvmcall" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (emit_llvmcall) pending.
(gdb) run

Thread 1 "julia" hit Breakpoint 1, emit_llvmcall (ctx=..., args=0x7fffe66ce4a0, nargs=3) at src/ccall.cpp:955
955         JL_NARGSV(llvmcall, 3);
(gdb) n
956         jl_value_t *rt = NULL, *at = NULL, *ir = NULL, *decl = NULL;
(gdb) 
957         JL_GC_PUSH4(&ir, &rt, &at, &decl);
(gdb) 
958         at = try_eval(ctx, args[3], "error statically evaluating llvmcall argument tuple", true);
(gdb) 
959         rt = try_eval(ctx, args[2], "error statically evaluating llvmcall return type", true);
(gdb) 
960         ir = try_eval(ctx, args[1], "error statically evaluating llvm IR argument", true);
(gdb) 
961         int i = 1;
(gdb) 
962         if (jl_is_tuple(ir)) {
(gdb) p ir
$1 = (jl_value_t *) 0x0
(gdb) n

Thread 1 "julia" received signal SIGSEGV, Segmentation fault.
0x00007ffff759f5fd in emit_llvmcall (ctx=..., args=0x7fffe66ce4a0, nargs=3) at src/ccall.cpp:962
962         if (jl_is_tuple(ir)) {

Breaks LLVM.jl, where the argument is LLVM.ref(fun::LLVM.Function)::Ptr{LLVM.Value}.

Ref #24113.

@maleadt maleadt added the regression Regression in behavior compared to a previous version label Dec 12, 2017
@vtjnash
Copy link
Member

vtjnash commented Dec 12, 2017

That's not really a bug, since the argument is required to be a literal.

@StefanKarpinski
Copy link
Member

Can we avoid segfaulting?

maleadt added a commit to maleadt/LLVM.jl that referenced this issue Dec 12, 2017
@maleadt
Copy link
Member Author

maleadt commented Dec 12, 2017

That's not really a bug, since the argument is required to be a literal.

Fair enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

4 participants