Closed ghostcow closed 9 years ago
OK, i recreated the bug with a more simple example:
tds = require 'tds'
q = tds.hash()
for i=1,5000 do
q[i]=torch.Tensor()
end
for i=1,100 do
print(q)
end
after a few prints this crashes, with the following error:
/home/lioruzan/torch/install/share/lua/5.1/tds/hash.lua:121: 'struct tds_hash_' has no '__ipairs' metamethod
stack traceback:
[C]: in function 'pairs'
/home/lioruzan/torch/install/share/lua/5.1/tds/hash.lua:121: in function 'tostring'
/home/lioruzan/torch/install/share/lua/5.1/trepl/init.lua:251: in function 'rawprint'
/home/lioruzan/torch/install/share/lua/5.1/trepl/init.lua:283: in function 'print'
[string "for i=1,100 do..."]:2: in main chunk
[C]: in function 'xpcall'
/home/lioruzan/torch/install/share/lua/5.1/trepl/init.lua:663: in function 'repl'
...uzan/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x00406670
this was run in a 'th' console on ubuntu 14.04.
I tried looking into the call stack but I couldn't find anything. why does 'struct tdshash' even show up in lua? isn't this supposed to be a 'hash' object?
cannot reproduce the bug. i guess you have a screwed up version of tds installed there, as ipairs should not be called on tds.Hash.
are you using lua or luajit? which version?
LuaJIT 2.1.0-alpha.
Just to be on the safe side, I ran
./upgrade.sh
./install.sh
luarocks install tds
waited till everything was updated and compiled, bug was still there.
more info about my system:
lioruzan@pc-lior:~/torch$ uname -a
Linux pc-lior 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Also worth noting that I recreated the bug on another system with a similar setup, but since I can't remember if I updated everything there too I'll focus on this computer only.
Hmmm, I reproduced the bug as well on my Ubuntu system.
It looks like a luajit bug. Maybe it's fixed in luajit 2.1 final release I have to check.
For example with JIT off, it runs smoothly:
luajit -joff bug.lua
Thanks Soumith!
If I don't use the ffi interface, will I break anything if I turn off LuaJIT?
@ghostcow no you wont break anything if you turn off jit (you can use FFI too)
thanks @soumith it was indeed a luajit bug updated luajit (in luajit-rocks repo) to last version
how to update luajit again?
@geoparser you'll have to reinstall torch by: cd ~/torch ./clean.sh git pull ./install.sh
thanks!
when printing a tds hash table, torch seems to try and use the "__ipairs" internal method and crashes because that method is not defined in the "hash" object.
when running
I get the following error:
The workaround I found was to just point back to the __pairs function:
but this isn't a permanent solution
the code in hash.lua:121 calls 'pairs' (not ipairs). Is there some way the two are connected? I couldn't figure it out.