tomblind / local-lua-debugger-vscode

Local Lua Debugger for VSCode
MIT License
106 stars 26 forks source link

LuaJit won't work in Linux #18

Closed shreyanshiitb closed 4 years ago

shreyanshiitb commented 4 years ago

Hi, It seems LauJit debugger is not working for me. It is not even getting started. debug console(VS code) shows this on pressing F5(starting debugger) :

/root/torch/install/bin/luajit: stack overflow
stack traceback:
    [C]: in function 'running'
    ....local-lua-debugger-vscode-0.1.7/debugger/lldebugger.lua:1200: in function 'assert'
    ....local-lua-debugger-vscode-0.1.7/debugger/lldebugger.lua:1200: in function 'assert'
    ....local-lua-debugger-vscode-0.1.7/debugger/lldebugger.lua:1200: in function 'assert'
    ....local-lua-debugger-vscode-0.1.7/debugger/lldebugger.lua:1200: in function 'assert'
    ....local-lua-debugger-vscode-0.1.7/debugger/lldebugger.lua:1200: in function 'assert'
    ....local-lua-debugger-vscode-0.1.7/debugger/lldebugger.lua:1200: in function 'assert'
    ....local-lua-debugger-vscode-0.1.7/debugger/lldebugger.lua:1200: in function 'assert'
    ....local-lua-debugger-vscode-0.1.7/debugger/lldebugger.lua:1067: in function '__index'
    preprocess.lua:4: in main chunk

whereas on bash this works perfectly

luajit preprocess.lua -sourcelang en -targetlang hi \
  -trainpref $TEXT/train -validpref $TEXT/valid -testpref $TEXT/test \
  -thresholdsrc 3 -thresholdtgt 3 -destdir data-bin/iitb

Steps to reproduce :

root@fe0c432a3c8d:~/NPMT# whereis luajit
luajit: /root/torch/install/bin/luajit

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Custom Lua Environment",
            "type": "lua-local",
            "request": "launch",
            "program": {
                "command": "/root/torch/install/bin/luajit"
            },
            "env": {
                "TEXT":"data/IITB_small",
                "LD_LIBRARY_PATH":"/usr/local/lib:$LD_LIBRARY_PATH"
            },
            "args": ["preprocess.lua","-sourcelang","en","-targetlang","hi","-trainpref","$TEXT/train","-validpref","$TEXT/valid","-testpref","$TEXT/test","-thresholdsrc","3","-thresholdtgt","3","-destdir","data-bin/iitb"]
        }
    ]
}

preprocess.lua


require 'fairseq'
require("lldebugger").start()

local tok = require 'fairseq.text.tokenizer'
local lmc = require 'fairseq.text.lm_corpus'
local plpath = require 'pl.path'
local pldir = require 'pl.dir'
...
...
...
shreyanshiitb commented 4 years ago

It now gives a different error. For my purpose, I have commented

        if type(value) == "table" then
            dbgVar.length = #value
        end

in lldebugger.lua file

/root/torch/install/bin/luajit: ....local-lua-debugger-vscode-0.1.8/debugger/lldebugger.lua:431: torch.CmdLine has no length operator
stack traceback:
    [C]: in function '__len'
    ....local-lua-debugger-vscode-0.1.8/debugger/lldebugger.lua:431: in function 'buildVariable'
    ....local-lua-debugger-vscode-0.1.8/debugger/lldebugger.lua:493: in function 'vars'
    ....local-lua-debugger-vscode-0.1.8/debugger/lldebugger.lua:903: in function 'debugBreak'
    ....local-lua-debugger-vscode-0.1.8/debugger/lldebugger.lua:1088: in function <....local-lua-debugger-vscode-0.1.8/debugger/lldebugger.lua:1063>
    preprocess.lua:10: in main chunk
    [C]: at 0x00405d50
tomblind commented 4 years ago

That's an interesting error. It looks like torch has a custom type that says it is a table, but does not support the length operator.

Commenting out that line will almost certainly cause issues with the debugger. Will you open a new issue for this? Also, please include the line in preprocess.lua (line 10) that triggers the issue. Thanks!