Package: lua-socket
Version: 3.0~rc1+git+321c0c9-1
Severity: normal

Dear Maintainer,

I'm trying to use socket.http from mpv. My script looks like this:

        $ cat test.lua
        local http = require("socket.http")
        local url = "http://rohieb.name";
        print ("MARK")
        d,c,h = http.request(url)
        print (("HTTP %d"):format(c))

... and works fine with the Lua 5.2 interpreter:

        $ lua5.2 test.lua
        MARK
        HTTP 200

However, when I use it with mpv, it segfaults on the http.request() line in
timeout_markstart(), see the attached GDB session transcript. A simple fix would
be to test for tm==0 in timeout_markstart(), but I'm not sure what is going on
here and why tm is 0 to begin with.

Cheers,

 - Roland

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'testing-proposed-updates'), (500, 
'testing-debug'), (500, 'testing'), (170, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.5.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages lua-socket depends on:
ii  libc6  2.22-7

lua-socket recommends no packages.

lua-socket suggests no packages.

-- no debconf information
$ gdb --args mpv --script=test.lua ~/Music/Moderat\ \'Bad\ 
Kingdom\'-3NPxqXMZq7o.mp4 
Reading symbols from mpv...(no debugging symbols found)...done.
(gdb) r
Starting program: /usr/bin/mpv --script=test.lua /home/rohieb/Music/Moderat\ 
\'Bad\ Kingdom\'-3NPxqXMZq7o.mp4
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffd85d1700 (LWP 4030)]
[New Thread 0x7fffd7dd0700 (LWP 4031)]
[New Thread 0x7fffd75cf700 (LWP 4032)]
[test] MARK 

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffd75cf700 (LWP 4032)]
timeout_markstart (tm=0x0) at src/timeout.c:115
115         tm->start = timeout_gettime();
(gdb) bt
#0  timeout_markstart (tm=0x0) at src/timeout.c:115
#1  0x00007fffd6bc5559 in buffer_meth_send (L=0x7fffcc000940, 
buf=0x7fffcc0495d0) at src/buffer.c:81
#2  0x00007ffff3489c4d in luaD_precall (L=L@entry=0x7fffcc000940, 
func=<optimized out>, func@entry=0x7fffcc011930, nresults=nresults@entry=-1) at 
ldo.c:319
#3  0x00007ffff349583d in luaV_execute (L=L@entry=0x7fffcc000940) at lvm.c:709
#4  0x00007ffff3489f8e in luaD_call (L=0x7fffcc000940, func=<optimized out>, 
nResults=<optimized out>, allowyield=<optimized out>) at ldo.c:402
#5  0x00007ffff34895cf in luaD_rawrunprotected (L=L@entry=0x7fffcc000940, 
f=f@entry=0x7ffff3484b70 <f_call>, ud=ud@entry=0x7fffd75ce600) at ldo.c:131
#6  0x00007ffff348a1d1 in luaD_pcall (L=L@entry=0x7fffcc000940, 
func=func@entry=0x7ffff3484b70 <f_call>, u=u@entry=0x7fffd75ce600, old_top=128, 
ef=<optimized out>) at ldo.c:603
#7  0x00007ffff34860f1 in lua_pcallk (L=L@entry=0x7fffcc000940, 
nargs=<optimized out>, nresults=nresults@entry=-1, errfunc=errfunc@entry=0, 
ctx=ctx@entry=0, k=k@entry=0x7fffd6bc9770 <protected_cont>) at lapi.c:949
#8  0x00007fffd6bc975f in protected_ (L=0x7fffcc000940) at src/except.c:107
#9  0x00007ffff3489c4d in luaD_precall (L=L@entry=0x7fffcc000940, 
func=<optimized out>, func@entry=0x7fffcc011810, nresults=nresults@entry=3) at 
ldo.c:319
#10 0x00007ffff349583d in luaV_execute (L=L@entry=0x7fffcc000940) at lvm.c:709
#11 0x00007ffff3489f8e in luaD_call (L=L@entry=0x7fffcc000940, func=<optimized 
out>, nResults=nResults@entry=0, allowyield=allowyield@entry=0) at ldo.c:402
#12 0x00007ffff348602b in lua_callk (L=0x7fffcc000940, nargs=<optimized out>, 
nresults=0, ctx=<optimized out>, k=<optimized out>) at lapi.c:905
#13 0x00005555555f0ac2 in ?? ()
#14 0x00007ffff3489c4d in luaD_precall (L=L@entry=0x7fffcc000940, 
func=<optimized out>, nresults=0) at ldo.c:319
#15 0x00007ffff3489f82 in luaD_call (L=0x7fffcc000940, func=<optimized out>, 
nResults=<optimized out>, allowyield=<optimized out>) at ldo.c:401
#16 0x00007ffff34895cf in luaD_rawrunprotected (L=L@entry=0x7fffcc000940, 
f=f@entry=0x7ffff3484b70 <f_call>, ud=ud@entry=0x7fffd75ce930) at ldo.c:131
#17 0x00007ffff348a1d1 in luaD_pcall (L=L@entry=0x7fffcc000940, 
func=func@entry=0x7ffff3484b70 <f_call>, u=u@entry=0x7fffd75ce930, old_top=48, 
ef=<optimized out>) at ldo.c:603
#18 0x00007ffff34860f1 in lua_pcallk (L=0x7fffcc000940, nargs=<optimized out>, 
nresults=0, errfunc=<optimized out>, ctx=<optimized out>, k=<optimized out>) at 
lapi.c:949
#19 0x00005555555f26bc in ?? ()
#20 0x00007ffff3489c4d in luaD_precall (L=L@entry=0x7fffcc000940, 
func=<optimized out>, nresults=0) at ldo.c:319
#21 0x00007ffff3489f82 in luaD_call (L=0x7fffcc000940, func=<optimized out>, 
nResults=<optimized out>, allowyield=<optimized out>) at ldo.c:401
#22 0x00007ffff34895cf in luaD_rawrunprotected (L=L@entry=0x7fffcc000940, 
f=f@entry=0x7ffff3484b70 <f_call>, ud=ud@entry=0x7fffd75ceb60) at ldo.c:131
#23 0x00007ffff348a1d1 in luaD_pcall (L=L@entry=0x7fffcc000940, 
func=func@entry=0x7ffff3484b70 <f_call>, u=u@entry=0x7fffd75ceb60, old_top=16, 
ef=<optimized out>) at ldo.c:603
#24 0x00007ffff34860f1 in lua_pcallk (L=0x7fffcc000940, nargs=<optimized out>, 
nresults=0, errfunc=<optimized out>, ctx=<optimized out>, k=<optimized out>) at 
lapi.c:949
#25 0x00005555555f2bb6 in ?? ()
#26 0x00005555555f7a99 in ?? ()
#27 0x00007ffff4925454 in start_thread (arg=0x7fffd75cf700) at 
pthread_create.c:334
#28 0x00007fffefd3ceed in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:109
(gdb) p tm
$1 = (p_timeout) 0x0
(gdb) up
#1  0x00007fffd6bc5559 in buffer_meth_send (L=0x7fffcc000940, 
buf=0x7fffcc0495d0) at src/buffer.c:81
81          timeout_markstart(buf->tm);
(gdb) p *buf
$2 = {birthday = 0, sent = 0, received = 0, io = 0x0, tm = 0x0, first = 0, last 
= 0, 
  data = '\000' <repeats 8191 times>}
(gdb) q

Reply via email to