andmarti1424 / sc-im

sc-im - Spreadsheet Calculator Improvised -- An ncurses spreadsheet program for terminal
Other
4.87k stars 208 forks source link

Segmentation fault when using @eqs with cell reference #598

Closed anveltn closed 3 years ago

anveltn commented 3 years ago

This occurs on main (v0.8.3-main) and dev but not on v0.8.2

To reproduce:

  1. Enter a string in A0.
  2. Enter =@eqs(A0, "anystring") into any other cell.
andmarti1424 commented 3 years ago

Thank you for reporting this. Could you please update to latest dev branch commit and retry? Thank you.

anveltn commented 3 years ago

Yep, that fixed it

andmarti1424 commented 3 years ago

I leave this open until I create the proper automatic test

vanrein commented 3 years ago

Probably the same bug (?) occurred in master 0d815ba3cb57b1facd3c55573f40975094b5f6d4 with unchanged Makefile:

  1. From the build's src directory, run gdb ./sc-im and start with r
  2. In cell C2, enter =@lua("print 3",C0)
  3. *boom Segmentation Fault
  4. Enter bt for the GDB backtrace

Backtrace output:

#0  0x0000555555586d1d in constant (e=0x2) at interp.c:1685
#1  0x00005555555862b3 in let (roman=0x5555556e51f0, sh=0x5555556e5240, v=0x5555556f80c0, e=0x2) at interp.c:1453
#2  0x000055555556b543 in yyparse () at gram.y:421
#3  0x000055555559ac2b in send_to_interp (oper=0x5555555c5820 <interp_line> L"let C2 = @lua(\"print 3\", C0)")
    at cmds/cmds.c:1266
#4  0x000055555559ab4e in enter_cell_content (sh=0x5555556e5240, r=2, c=2, submode=0x7fffffff99f0 "let", 
    content=0x7fffffff9df0 L"@lua(\"print 3\", C0)") at cmds/cmds.c:1244
#5  0x0000555555597350 in do_insertmode (sb=0x5555556eb500) at cmds/cmds_insert.c:213
#6  0x0000555555564ab2 in exec_single_cmd (sb=0x5555556eb500) at input.c:338
#7  0x0000555555564c24 in exec_mult (buf=0x5555556eb500, timeout=195) at input.c:401
#8  0x0000555555564b80 in handle_mult (cmd_multiplier=0x5555555c24c4 <cmd_multiplier>, buf=0x5555556eb500, timeout=195)
    at input.c:377
#9  0x000055555556475d in handle_input (buffer=0x5555556eb500) at input.c:214
#10 0x0000555555563756 in main (argc=1, argv=0x7fffffffe0b8) at main.c:340

Note that e != NULL but it is not a valid pointer either.

The same result for =@lua("print 4",1) or =@lua("print 4",0) by the way.

Further information, but probably not related to this problem:

shell$ dpkg -l \*lua\* | grep ^ii
ii  liblua5.1-0:amd64    5.1.5-8.1+b2          amd64        Shared library for the Lua interpreter version 5.1
ii  liblua5.2-0:amd64    5.2.4-1.1+b2          amd64        Shared library for the Lua interpreter version 5.2
ii  liblua5.2-dev:amd64  5.2.4-1.1+b2          amd64        Development files for the Lua language version 5.2
ii  libtexlua52:amd64    2018.20181218.49446-1 amd64        TeX Live: Lua 5.2, modified for use with LuaTeX
ii  libtexlua53:amd64    2018.20181218.49446-1 amd64        TeX Live: Lua 5.3, modified for use with LuaTeX
ii  libtexluajit2:amd64  2018.20181218.49446-1 amd64        TeX Live: LuaJIT, modified for use with LuaJITTeX
ii  lua-bitop:amd64      1.0.2-5               amd64        fast bit manipulation library for the Lua language
ii  lua-event:amd64      0.4.6-1               amd64        asynchronous event notification library for Lua
ii  lua-expat:amd64      1.3.0-4               amd64        libexpat bindings for the Lua language
ii  lua-filesystem:amd64 1.6.3-1               amd64        luafilesystem library for the Lua language
ii  lua-ldap:amd64       1.2.5-1               amd64        LDAP library for the Lua language
ii  lua-sec:amd64        0.7-1                 amd64        SSL socket library for the Lua language
ii  lua-socket:amd64     3.0~rc1+git+ac3201d-4 amd64        TCP/UDP socket library for the Lua language
ii  lua5.2               5.2.4-1.1+b2          amd64        Simple, extensible, embeddable programming language
ii  lua5.3               5.3.3-1.1             amd64        Simple, extensible, embeddable programming language
vanrein commented 3 years ago

I also had this problem on the dev branch, with latest commit a213b2daadbebe5792450e65ef0ee28e2f02b4ca.

andmarti1424 commented 3 years ago

@vanrein that seems to be a totally different issue. I cant get it to segfault. Btw, I believe you should enter the @lua as string function with \"