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

Version 0.7.0-rc1.0, permutedims crash with Illegal inttoptr #28388

Closed
PaulSoderlind opened this issue Aug 1, 2018 · 18 comments
Closed

Version 0.7.0-rc1.0, permutedims crash with Illegal inttoptr #28388

PaulSoderlind opened this issue Aug 1, 2018 · 18 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently
Milestone

Comments

@PaulSoderlind
Copy link
Contributor

This crashes Version 0.7.0-rc1.0, Win64

x = rand(4,3,2)
y = permutedims(x,[3,1,2])
@fredrikekre
Copy link
Member

fredrikekre commented Aug 1, 2018

Same on Linux; full stacktrace:

julia> y = permutedims(x,[3,1,2])
Illegal inttoptr
	  %49 = ptrtoint double addrspace(13)* %48 to i64
Illegal inttoptr
	  %104 = inttoptr i64 %103 to i8 addrspace(13)*

signal (6): Aborted
in expression starting at no file:0
raise at /build/glibc-Cl5G7W/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54
abort at /build/glibc-Cl5G7W/glibc-2.23/stdlib/abort.c:89
runOnFunction at /home/fredrik/julia-master/src/llvm-gc-invariant-verifier.cpp:178
_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at /home/fredrik/julia-master/usr/bin/../lib/libLLVM-6.0.so (unknown line)
_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at /home/fredrik/julia-master/usr/bin/../lib/libLLVM-6.0.so (unknown line)
_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at /home/fredrik/julia-master/usr/bin/../lib/libLLVM-6.0.so (unknown line)
operator() at /home/fredrik/julia-master/src/jitlayers.cpp:481
addModule at /home/fredrik/julia-master/usr/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h:57 [inlined]
addModule at /home/fredrik/julia-master/src/jitlayers.cpp:608
jl_add_to_ee at /home/fredrik/julia-master/src/jitlayers.cpp:855 [inlined]
jl_finalize_function at /home/fredrik/julia-master/src/jitlayers.cpp:863
getAddressForFunction at /home/fredrik/julia-master/src/codegen.cpp:1300
jl_generate_fptr at /home/fredrik/julia-master/src/codegen.cpp:1411
jl_compile_method_internal at /home/fredrik/julia-master/src/gf.c:1804 [inlined]
jl_fptr_trampoline at /home/fredrik/julia-master/src/gf.c:1811
jl_apply_generic at /home/fredrik/julia-master/src/gf.c:2165
do_call at /home/fredrik/julia-master/src/interpreter.c:324
eval_value at /home/fredrik/julia-master/src/interpreter.c:428
eval_stmt_value at /home/fredrik/julia-master/src/interpreter.c:363 [inlined]
eval_body at /home/fredrik/julia-master/src/interpreter.c:682
jl_interpret_toplevel_thunk_callback at /home/fredrik/julia-master/src/interpreter.c:799
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f31983d850f)
unknown function (ip: (nil))
jl_interpret_toplevel_thunk at /home/fredrik/julia-master/src/interpreter.c:808
jl_toplevel_eval_flex at /home/fredrik/julia-master/src/toplevel.c:831
jl_toplevel_eval_in at /home/fredrik/julia-master/src/builtins.c:633
eval at ./boot.jl:319
jl_apply_generic at /home/fredrik/julia-master/src/gf.c:2165
eval_user_input at /home/fredrik/julia-master/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:85
macro expansion at /home/fredrik/julia-master/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:117 [inlined]
#28 at ./task.jl:262
jl_fptr_trampoline at /home/fredrik/julia-master/src/gf.c:1812
jl_apply_generic at /home/fredrik/julia-master/src/gf.c:2165
jl_apply at /home/fredrik/julia-master/src/julia.h:1538 [inlined]
start_task at /home/fredrik/julia-master/src/task.c:268
unknown function (ip: 0xffffffffffffffff)
Allocations: 5796103 (Pool: 5794648; Big: 1455); GC: 12
Aborted (core dumped)

Looks related to Keno's recent LLVM fixes?

Edit:

julia> versioninfo()
Julia Version 0.7.0-rc1.4
Commit 0ef8826 (2018-08-01 00:52 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

@fredrikekre fredrikekre changed the title Version 0.7.0-rc1.0, Win64, crash Version 0.7.0-rc1.0, permutedims crash with Illegal inttoptr Aug 1, 2018
@fredrikekre fredrikekre added the bug Indicates an unexpected problem or unintended behavior label Aug 1, 2018
@fredrikekre
Copy link
Member

Probably dup of #28379?

@dlfivefifty
Copy link
Contributor

If it is a dup, better to close #28379 as this is a much better MWE.

@gdkrmr
Copy link
Contributor

gdkrmr commented Aug 1, 2018

I cannot reproduce this on 0.7.0-rc1.5, Ubuntu 16.04

@dlfivefifty
Copy link
Contributor

I get it on rc1.4:

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0-rc1.4 (2018-08-01 00:52 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 0ef882679f (0 days old master)
|__/                   |  x86_64-apple-darwin17.7.0

julia> x = rand(4,3,2)
4×3×2 Array{Float64,3}:
[:, :, 1] =
 0.547093  0.681695  0.259469 
 0.450266  0.939295  0.590317 
 0.925171  0.85919   0.548892 
 0.182937  0.288661  0.0223785

[:, :, 2] =
 0.151585    0.0777777  0.167315
 0.333083    0.595943   0.748375
 0.00221635  0.153361   0.20937 
 0.613113    0.0917188  0.383782

julia> y = permutedims(x,[3,1,2])
Illegal inttoptr
	  %49 = ptrtoint double addrspace(13)* %48 to i64
Illegal inttoptr
	  %104 = inttoptr i64 %103 to i8 addrspace(13)*

signal (6): Abort trap: 6
in expression starting at no file:0
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Allocations: 5956874 (Pool: 5955405; Big: 1469); GC: 12
Abort trap: 6

@StefanKarpinski StefanKarpinski added the priority This should be addressed urgently label Aug 1, 2018
@StefanKarpinski StefanKarpinski added this to the 0.7 milestone Aug 1, 2018
@timholy
Copy link
Member

timholy commented Aug 1, 2018

Just FYI, I don't on what is basically the same (it has one more commit, #28386):

julia> versioninfo()
Julia Version 0.7.0-rc1.4
Commit 0ef882679f* (2018-08-01 00:52 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, broadwell)
Environment:
  JULIAFUNCDIR = /home/tim/juliafunc
  JULIA_CPU_THREADS = 2

@fredrikekre
Copy link
Member

For those of you who do not get this failure, have you rebuilt llvm after Keno's patches? (i.e. make -C deps distclean-llvm)

@gdkrmr
Copy link
Contributor

gdkrmr commented Aug 1, 2018

llvm was rebuilt today but I did not have to make -C deps distclean-llvm

@mgr327
Copy link

mgr327 commented Aug 1, 2018

I do not get this failure on two different machines, both 0.7.0-rc1.5 on Fedora. I did make -C deps distclean-llvm one one machine (yesterday, for rc1.4 I believe) but not today on the other machine. Today's build 'recognized' by itself that there are patches to llvm that need to be applied...

versioninfo()
Julia Version 0.7.0-rc1.5
Commit 25a8c95 (2018-08-01 11:41 UTC)
Platform Info:
OS: Linux (x86_64-redhat-linux)
CPU: Intel(R) Xeon(R) CPU X5650 @ 2.67GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, westmere)

@vchuravy
Copy link
Member

vchuravy commented Aug 1, 2018

That sounds like #28377 fixed this occurrence. Recent LLVM patches have not caused a recompilation of LLVM due to a sticky patch at the end, now they should retrigger a compilation when they get applied.

@Keno
Copy link
Member

Keno commented Aug 1, 2018

I can still reproduce this after patches, so I'll take a look.

@rened
Copy link
Member

rened commented Aug 1, 2018

@fredrikekre I got this error when trying to build rc1.4 without make -C deps distclean-llvm, at the very end of the build process, after the sysimg stuff.

After building from a fresh checkout, the MWE works as intended here:

Julia Version 0.7.0-rc1.4
Commit 0ef8826 (2018-08-01 00:52 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2640 v4 @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, broadwell)
Environment:
  JULIA_SHELL = /bin/bash

@timholy timholy mentioned this issue Aug 1, 2018
7 tasks
@gdkrmr
Copy link
Contributor

gdkrmr commented Aug 1, 2018

On a machine where I did make -C deps distclean-llvm last Saturday:

julia> versioninfo()
Julia Version 0.7.0-beta2.171
Commit cf78a31* (2018-07-29 03:54 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i5-3470S CPU @ 2.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)

is fine, after a recompile with a partial rebuild of llvm it is still fine

julia> versioninfo()
Julia Version 0.7.0-rc1.8
Commit fef6d02* (2018-08-01 15:52 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i5-3470S CPU @ 2.90GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)

@Keno
Copy link
Member

Keno commented Aug 1, 2018

Looks like this one is architecture dependent. Reduced testcase (opt -loop-vectorize -mcpu skylake-avx512):

; ModuleID = 'bugpoint-reduced-simplified.bc'
source_filename = "bugpoint-output-db8c91b.bc"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:10:11:12:13"
target triple = "x86_64-unknown-linux-gnu"

%jl_value_t = type opaque
%jl_array_t = type { i8 addrspace(13)*, i64, i16, i16, i32 }

; Function Attrs: sspstrong
define void @"japi1_permutedims!_33509"(%jl_value_t addrspace(10)**) #0 {
top:
  %1 = alloca [3 x i64], align 8
  %2 = load %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %0, align 8, !nonnull !1, !dereferenceable !2, !align !3
  %3 = getelementptr inbounds %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %0, i64 1
  %4 = load %jl_value_t addrspace(10)*, %jl_value_t addrspace(10)** %3, align 8, !nonnull !1, !dereferenceable !2, !align !3
  %5 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 0, i64 0
  store i64 1, i64* %5, align 8, !tbaa !4
  %6 = getelementptr inbounds [3 x i64], [3 x i64]* %1, i64 0, i64 undef
  %7 = load i64, i64* inttoptr (i64 24 to i64*), align 8, !tbaa !7, !invariant.load !1
  %8 = addrspacecast %jl_value_t addrspace(10)* %4 to %jl_value_t addrspace(11)*
  %9 = bitcast %jl_value_t addrspace(11)* %8 to double addrspace(13)* addrspace(11)*
  %10 = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %9, align 8, !tbaa !7, !invariant.load !1, !nonnull !1
  %11 = addrspacecast %jl_value_t addrspace(10)* %2 to %jl_value_t addrspace(11)*
  %12 = bitcast %jl_value_t addrspace(11)* %11 to double addrspace(13)* addrspace(11)*
  %13 = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %12, align 8, !tbaa !7, !invariant.load !1, !nonnull !1
  %14 = load i64, i64* %6, align 8, !tbaa !4
  br label %L54

L54:                                              ; preds = %L94, %top
  br label %L74

L74:                                              ; preds = %L74, %L54
  %value_phi20 = phi i64 [ undef, %L54 ], [ %22, %L74 ]
  %value_phi21 = phi i64 [ undef, %L54 ], [ %23, %L74 ]
  %value_phi22 = phi i64 [ 1, %L54 ], [ %25, %L74 ]
  %15 = add i64 %value_phi21, -1
  %16 = getelementptr inbounds double, double addrspace(13)* %10, i64 %15
  %17 = bitcast double addrspace(13)* %16 to i64 addrspace(13)*
  %18 = load i64, i64 addrspace(13)* %17, align 8, !tbaa !9
  %19 = add i64 %value_phi20, -1
  %20 = getelementptr inbounds double, double addrspace(13)* %13, i64 %19
  %21 = bitcast double addrspace(13)* %20 to i64 addrspace(13)*
  store i64 %18, i64 addrspace(13)* %21, align 8, !tbaa !9
  %22 = add i64 %value_phi20, 1
  %23 = add i64 %14, %value_phi21
  %24 = icmp eq i64 %value_phi22, %7
  %25 = add i64 %value_phi22, 1
  br i1 %24, label %L94, label %L74

L94:                                              ; preds = %L74
  br label %L54
}

attributes #0 = { sspstrong "target-cpu"="skylake-avx512" "thunk" }

!llvm.module.flags = !{!0}

!0 = !{i32 1, !"Debug Info Version", i32 3}
!1 = !{}
!2 = !{i64 40}
!3 = !{i64 16}
!4 = !{!5, !5, i64 0}
!5 = !{!"jtbaa_stack", !6, i64 0}
!6 = !{!"jtbaa"}
!7 = !{!8, !8, i64 0, i64 1}
!8 = !{!"jtbaa_const", !6, i64 0}
!9 = !{!10, !10, i64 0}
!10 = !{!"jtbaa_arraybuf", !11, i64 0}
!11 = !{!"jtbaa_data", !6, i64 0}

@Keno
Copy link
Member

Keno commented Aug 2, 2018

Candidate patch at https://reviews.llvm.org/D50167.

Keno added a commit that referenced this issue Aug 2, 2018
Keno added a commit that referenced this issue Aug 2, 2018
Keno added a commit that referenced this issue Aug 2, 2018
* Add LLVM patch to explicitly represent umin in SCEV

Fixes #28379
Fixes #28388

* bump LLVM BB_REL 6.0.0-6
KristofferC pushed a commit that referenced this issue Feb 11, 2019
* Add LLVM patch to explicitly represent umin in SCEV

Fixes #28379
Fixes #28388

* bump LLVM BB_REL 6.0.0-6
@jhgoulart
Copy link

jhgoulart commented Jul 22, 2020

I had the same issue today on a fresh install (couple of weeks ago) of julia 1.4.1, on Ubuntu.

Shouldn't this have already been corrected with the patch you mentioned? Or do I have to manually take some action?

Here is the error message:

Illegal inttoptr
      %33 = ptrtoint double addrspace(13)* %32 to i64
Illegal inttoptr
      %64 = inttoptr i64 %63 to i8 addrspace(13)*

signal (6): Abandon
in expression starting at none:0
gsignal at /usr/bin/../lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /usr/bin/../lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7f20d3330d04)
_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
unknown function (ip: 0x7f20d341aac1)
unknown function (ip: 0x7f20d341d2d8)
unknown function (ip: 0x7f20d341d8cd)
unknown function (ip: 0x7f20d3358b4a)
unknown function (ip: 0x7f20d338a082)
unknown function (ip: 0x7f20d33af84b)
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/libjulia.so.1 (unknown line)
unknown function (ip: 0x7f20d33c275b)
unknown function (ip: 0x7f20d33c2389)
unknown function (ip: 0x7f20d33c28f0)
unknown function (ip: 0x7f20d33c39c8)
unknown function (ip: 0x7f20d33c4616)
unknown function (ip: 0x7f20d33dce08)
jl_toplevel_eval_in at /usr/bin/../lib/x86_64-linux-gnu/libjulia.so.1 (unknown line)
eval at ./boot.jl:331 [inlined]
repleval at /home/user/.julia/packages/Atom/isnka/src/repl.jl:196
#246 at /home/user/.julia/packages/Atom/isnka/src/repl.jl:223
with_logstate at ./logging.jl:398
with_logger at ./logging.jl:505 [inlined]
evalrepl at /home/user/.julia/packages/Atom/isnka/src/repl.jl:214
unknown function (ip: 0x7f20d33c275b)
unknown function (ip: 0x7f20d33c2389)
unknown function (ip: 0x7f20d33c28f0)
unknown function (ip: 0x7f20d33c39c8)
unknown function (ip: 0x7f20d33c4616)
unknown function (ip: 0x7f20d33dce08)
jl_toplevel_eval_in at /usr/bin/../lib/x86_64-linux-gnu/libjulia.so.1 (unknown line)
eval at ./boot.jl:331
eval_user_input at /build/julia-98cBbp/julia-1.4.1+dfsg/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
macro expansion at /build/julia-98cBbp/julia-1.4.1+dfsg/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:118 [inlined]
#26 at ./task.jl:358
unknown function (ip: 0x7f20d33c7cbb)
unknown function (ip: (nil))
Allocations: 42560000 (Pool: 42551626; Big: 8374); GC: 39

@jhgoulart
Copy link

The problem was that I was using the julia version provided by apt, which is apparently quite buggy.

I switched to the version provided in julialang.org; it now works as expected.

@yuyichao
Copy link
Contributor

This was a LLVM bug so it was fixed in LLVM and not julia. This particular one is fixed on LLVM 9 but in general there are many other LLVM bugs that we are affected by requiring the use of our patched version of LLVM. You need to use a LLVM version with our patches and if you don't have that from your distro then you need to use the prebuilt binary from julialang.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior priority This should be addressed urgently
Projects
None yet
Development

No branches or pull requests