Jutho/TensorKit.jl

deepcopy of TensorMap causes Julia to crash (used in e.g. `exp`)

orialb opened this issue · 6 comments

Hi,
I started playing with your package in order to add U(1) charge conservation to my MPS code and it looks really promising. So first of all- thanks!
I encountered an issue with using exp function, which seems to actually originate from deepcopy of a tensor. This happens on both linux and macOS. Am I doing something wrong?

MWE:

using TensorKit
S = U₁Space(-1=>1,1=>1)
W=  S  S => S  S
t = TensorMap(rand,Float64,W)
exp(t) # (or just deepcopy(t) ) 

This results in

Unreachable reached at 0x7ff30576b5d5

signal (4): Illegal instruction
in expression starting at no file:0
deepcopy at ./deepcopy.jl:28
copy at /home/USER/.julia/packages/TensorKit/Y6AiJ/src/tensors/tensor.jl:171
exp at /home/USER/.julia/packages/TensorKit/Y6AiJ/src/tensors/linalg.jl:24
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1864
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:323
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:411
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:362 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:773
jl_interpret_toplevel_thunk_callback at /buildworker/worker/package_linux64/build/src/interpreter.c:885
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7ff316563c5f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:894
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:764
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/toplevel.c:793
eval at ./boot.jl:328
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:85
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/REPL/src/REPL.jl:117 [inlined]
#26 at ./task.jl:259
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2219
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1571 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:572
unknown function (ip: 0xffffffffffffffff)
Allocations: 18209101 (Pool: 18205573; Big: 3528); GC: 41
Illegal instruction (core dumped)

here is the version info for the linux machine:

Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, haswell)
Jutho commented

This is an error which I've also encountered (in a different setting) since Julia 1.1.0. It should be fixed by the latest commit however, so if you are working on master instead of the release version (there is only one so far), this will hopefully be fixed.

As a general warning; I am still finishing this package up to an official release. Most things should work, but could still change and there might be subtle bugs here and there. I hope to invest some time over summer to finally release this package (with completed documentation).

Indeed it doesn't crash working with master , but I then get a different error for exp:
ERROR: MethodError: no method matching exp!(::Array{Float64,2}).
changing exp!(b) to exp(b) in

copyto!(b, exp!(b))

solves it.

As a general warning; I am still finishing this package up to an official release

Got it, I'll try to work with it anyway because I'm assuming that your implementation is already much better and complete than what I can come up with. Maybe I can help find some of those subtle bugs :)

Should I open issues (and hopefully provide solutions) if I encounter them or should I wait until the official release?

(EDIT: I just realized that you meant your package master, not sure why I thought you meant julia master)

Jutho commented

Yes, that's the correct fix. exp! used to be an internal function in LinearAlgebra in Julia 1.0, but then was removed in 1.1. Since it was not exported, I guess that happened in one release cycle without deprecation.

All bug reports and issues are more than welcome.

Yes, that's the correct fix.

do you want a PR for this?

Jutho commented

I might have misremembered, but now checked that exp! is still available in LinearAlgebra, so just replacing exp! with LinearAlgebra.exp! is what you need.

Jutho commented

I've pushed a bunch of commits and tagged a new version, so this should now be officially fixed.