TheLinx / lao

A library for audio output through Lua.
http://thelinx.github.com/lao/
18 stars 2 forks source link

ao.openLive() errs or segfaults (depending) #1

Closed hryx closed 10 years ago

hryx commented 10 years ago

I have lao installed on OS X 10.8.5 and on a Linux Mint 14 Virtualbox VM, both via luarocks. I'm running the example Lua script.

On OS X, ao.openLive() causes a segmentation fault. On Mint, at least it just errs: Lua prints the default error "something went wrong", returned from l_open_live.

Not sure if this is the cause, but when trying to compile I get complaints that the ao_option *opt inside table2option can return uninitialized. As noted here, that means it points to jibberish: http://stackoverflow.com/a/7150353

Either way, passing an option table to ao.openLive() doesn't help -- segfault persists.

bartbes commented 10 years ago

I've cleaned the code up a bit, does it work now? For me it's just failing to open a device.

hryx commented 10 years ago

Output:

lao example script
ao_macosx ERROR: Unrecognized channel name "�r��" in channel matrix "�r��"
ao_macosx WARNING: Input channel matrix invalid; ignoring.
Segmentation fault: 11
bartbes commented 10 years ago

Alright, it appears the channel matrix was never initialized, try it now?

hryx commented 10 years ago

On OS X there is still a segfault, but on the Linux VM it only fails to open the device. At least there's that!

It could be that our different audio device setups give different results, but that shouldn't be crashing it.

Compiling with warnings gives no useful info. Maybe I can turn on debugging. Lemme know if you have any ideas.

bartbes commented 10 years ago

Did the plugin error at least disappear? Could you maybe attach a debugger and find out where it segfaults?

hryx commented 10 years ago

Yep, no plugin errors anymore. I'll give gdb a shot.

hryx commented 10 years ago

After a spate of useless JACK-related warnings...

..................................................................... done
Reading symbols for shared libraries . done

Program received signal EXC_ARITHMETIC, Arithmetic exception.
0x0000000100098945 in ao_play ()
bartbes commented 10 years ago

Does this happen with the examples? With everything? Does it happen with other libao applications?

And lastly, can you give me a backtrace, too?

hryx commented 10 years ago

I've only been running the example. I did change require('bit') --> require('bit32') but it's unrelated -- doesn't get called before the crash.

(Aside: probably not good to require such external libs in example code. A user who doesn't already have bit32 can't just download and immediately test lao.)

Can you name another libao application I can test?

Sure thing, I'll get you a backtrace.

hryx commented 10 years ago

I didn't set any breakpoints or anything (I'm not experienced with debuggers/programming/life). Shouldn't these be showing each called function's arguments?

Program received signal EXC_ARITHMETIC, Arithmetic exception.
0x0000000100098945 in ao_play ()
(gdb) bt
#0  0x0000000100098945 in ao_play ()
#1  0x0000000100092075 in l_play (L=0x1001038d0) at src/lao.c:192
#2  0x0000000100008d1a in luaD_precall ()
#3  0x0000000100011c6f in luaV_execute ()
#4  0x0000000100009084 in luaD_call ()
#5  0x0000000100008746 in luaD_rawrunprotected ()
#6  0x00000001000092e9 in luaD_pcall ()
#7  0x0000000100005733 in lua_pcall ()
#8  0x00000001000015a4 in docall ()
#9  0x000000010000119c in pmain ()
#10 0x0000000100008d1a in luaD_precall ()
#11 0x0000000100009073 in luaD_call ()
#12 0x0000000100008746 in luaD_rawrunprotected ()
#13 0x00000001000092e9 in luaD_pcall ()
#14 0x0000000100005791 in lua_cpcall ()
#15 0x0000000100000cb9 in main ()
(gdb) x 0x1001038d0
0x1001038d0:    0x00116e60
(gdb)
bartbes commented 10 years ago

I fixed the only things I could see wrong with that function, if this doesn't fix it.. I'm out of ideas. The message seems to suggest a divide-by-zero error, but with the examples and the code, those seem unlikely.

hryx commented 10 years ago

Hey Bart, I was able to get it to play back with the latest update -- no crashes! This was on a different computer, though (my work laptop), so I'll try from home too.

The audio from the example sounds like noise, so I tried filling the table with a plain sine wave but that doesn't sound any better. I'll have to look at what libao expects (interleaved samples or not, etc.).

Installing from LuaRocks still crashes, but I dunno if the rock is up to date. And oddly, playing from LuaJIT still crashes.

bartbes commented 10 years ago

The rock is indeed not up to date. Is it otherwise working now?

hryx commented 10 years ago

With the latest code it no longer crashes when opening a device, at least on stock Lua. It still crashes on LuaJIT but that might be worth a separate ticket. I'd say this one can be closed.

The sound I'm getting is totally unpredictable, but that too is for another ticket.

Thanks, Bart!

bartbes commented 10 years ago

Yeah, the state of lao seems.. not that good.