Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

lua crashes while using luajson #141

Closed
aisbaa opened this issue Apr 17, 2013 · 9 comments
Closed

lua crashes while using luajson #141

aisbaa opened this issue Apr 17, 2013 · 9 comments
Assignees

Comments

@aisbaa
Copy link

aisbaa commented Apr 17, 2013

To reproduce:

  1. bootstrap new lua
  2. run code below with lua interpreter
local json = require "json"
local jss = json.decode("")

I get segmentation fault.

$ luadist list

Installed modules:
==================

  lpeg-0.11 (-x86_64)
  lua-5.1.5 (-x86_64)
  lua-git-0.5   (-x86_64)
  luadist-activate-0.3  (-x86_64)
  luadist-git-0.2.5 (-x86_64)
  luafilesystem-1.6.2   (-x86_64)
  luajson-1.2.1 (-x86_64)
  luasocket-2.0.2   (-x86_64)
  penlight-1.1  (-x86_64)
  srlua-5.2 (-x86_64)
  zlib-1.2.6    (-x86_64)
@drahosp
Copy link
Member

drahosp commented Apr 17, 2013

Thank you for reporting, I will look into it. I see the bootstrap process fails to detect your system name, can you also post uname -a please.

@ghost ghost assigned drahosp Apr 17, 2013
@drahosp
Copy link
Member

drahosp commented Apr 17, 2013

I failed to reproduce the issue on OSX and Ubuntu Linux. Waiting for details about your os/system.

@aisbaa
Copy link
Author

aisbaa commented Apr 18, 2013

Sure, I use Archlinux, I'll try on ubuntu today.

Linux  3.8.4-1-ARCH #1 SMP PREEMPT Wed Mar 20 22:10:25 CET 2013 x86_64 GNU/Linux

@aisbaa
Copy link
Author

aisbaa commented Apr 19, 2013

Tried Ubuntu 12.04 and Ubuntu 12.10 (both 64-bit) and was unable to reproduce the crash,
but succeeded on Debian-stable (64-bit) and ArchLinux (64-bit). Also I've noticed that lpeg.so has
some internal functions visible which is generally not a good idea. There is an assumption, that
depending on OS environment loader might put wrong address to the function name breaking codeflow
logic.

One more question would be is there any documented way to strip all non-exported symbols
from libraries in LuaDist? CMake should be used in some way to declare libary linking policy.

gdb backtrace and lpeg symbols

@drahosp
Copy link
Member

drahosp commented Apr 19, 2013

Thank you.
LuaDist compiles the code as is and will strip the final executable unless you build it with debug enabled. Generally default CMake settings make sense in this context for all target platforms and compilers.

I will try to replicate the issue on my end using Debian and investigate possible solutions.

Please can you also try using lpeg-0.10.2 and see if the error persists.

> luadist remove lpeg
> luadist install lpeg-0.10.2

@mnicky
Copy link
Member

mnicky commented Apr 19, 2013

I have a 32-bit Debian 6.0 so I tried, just out of my curiosity, whether I can reproduce this:

$ bin/luadist install luajson -debug
$ bin/lua
> json = require "json"
> jss = json.decode('')
.../tmp/LuaDist/bin/../lib/lua/json/decode.lua:91: Invalid JSON data
stack traceback:
    [C]: in function 'assert'
    .../tmp/LuaDist/bin/../lib/lua/json/decode.lua:91: in function <.../tmp/LuaDist/bin/../lib/lua/json/decode.lua:89>
    (tail call): ?
    (tail call): ?
    stdin:1: in main chunk
    [C]: ?
> jss = json.decode('{"key": "val"}')
> return jss
table: 0x905c2e8
> for k,v in pairs(jss) do print(k,v) end
key val

...and it seems to be working.

@aisbaa
Copy link
Author

aisbaa commented Apr 19, 2013

Using lpeg-0.10.2 worked for me.

@dhkolf
Copy link

dhkolf commented Oct 13, 2013

This is a problem with LPeg 0.11 and is fixed for LPeg 0.12. Here is a discussion about it: http://lua-users.org/lists/lua-l/2013-04/msg00327.html

@drahosp
Copy link
Member

drahosp commented Oct 16, 2013

Marking this as wont-fix. The solution is to update to lpeg 0.12 which is now available in the repository. Thank you!

@drahosp drahosp closed this as completed Oct 16, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants