devcurmudgeon / alo

A Looper plugin for MOD duo
MIT License
20 stars 6 forks source link

Segfault with Jalv #1

Closed jkbd closed 6 years ago

jkbd commented 6 years ago

Hi @devcurmudgeon, thank you for your effort so far! When I start the ALo-plugin like this

$ time jalv http://devcurmudgeon.com/alo

on a PC it results in a segmentation fault after 65 seconds. Also the MOD Plugin Benchmark fails:

$ ./lv2bm --full-test http://devcurmudgeon.com/alo
*** stack smashing detected ***: <unknown> terminated
Abgebrochen (Speicherabzug geschrieben)
devcurmudgeon commented 6 years ago

Oh dear.... currently I've not tested on anything but the Duo. Does it work at all on the PC, before the segfault?

devcurmudgeon commented 6 years ago

Regarding the MOD Plugin Benchmark, i'm not sure how to run that in my scenario - using the docker toolchain as described on the mod wiki.

Would it make sense to set up this benchmark tool as part of CI for mod-plugin-builder?

devcurmudgeon commented 6 years ago

@jkbd I've pushed a fix to stop the loop ever being longer than the preset memory. Please could you check if this fixes the stack-smashing?

jkbd commented 6 years ago

I tried again

$ time jalv http://devcurmudgeon.com/alo

No crash in 20 minutes. Looks good!

jkbd commented 6 years ago

This works:

$ ./lv2bm  http://devcurmudgeon.com/alo
Plugin: http://devcurmudgeon.com/alo, Input signal: Sine Wave
    TestName  TotalTime(s)   AvrTime(s)  JackLoad(%)
   MinValues    0.00192118   0.00000512     0.384236
   DefValues    0.00188395   0.00000502     0.376790
   MaxValues    0.00279050   0.00000744     0.558101

but the following, again, does not:

$ ./lv2bm --full-test http://devcurmudgeon.com/alo
*** stack smashing detected ***: <unknown> terminated
Abgebrochen (Speicherabzug geschrieben)

I can't give you any hint by now.

devcurmudgeon commented 6 years ago

hmmm.... that's not the most helpful of messages :) you're sure this is with master?

jkbd commented 6 years ago

Double checked that. It's commit dc92409d7aa68a6c32056e820b9658aa43c94272. Maybe I can be more helpful later.

devcurmudgeon commented 6 years ago

That's not an alo commit?

jkbd commented 6 years ago

Sorry, that's the sha1sum of the shared library on my PC. I meant 277ddd864554fe81e2224a2b5d39122a1edcc0f9.

devcurmudgeon commented 6 years ago

how/where are you running this to test?

jalv and lv2bm are not in the mpb docker container. i've managed to get them running on a vanilla ubuntu machine, but that leaves me wondering what i need to do to construct alo there...

jkbd commented 6 years ago

What I did is

$ git clone git@github.com:devcurmudgeon/alo.git
$ cd alo/source
$ make DEBUG=true
$ cp -r alo.lv2/ ~/.lv2/

Then I can check if the plugin can be found on the LV2 path:

$ lv2ls | grep alo
http://devcurmudgeon.com/alo

It is found. Since jalv is available on $PATH on my system I can run it everywhere. It requires the Jack server to be running.

For that benchmark I did:

$ cd $MY_GITHUB_DIR
$ git clone git@github.com:moddevices/lv2bm.git
$ cd lv2bm
$ make DEBUG=1

I run the benchmark without installing it on the system.

$ ./lv2bm --full-test http://devcurmudgeon.com/alo
*** stack smashing detected ***: <unknown> terminated
Abgebrochen (Speicherabzug geschrieben)

This is neither news nor helpful. Let's run it with gdb:

$ gdb --args ./lv2bm --full-test http://devcurmudgeon.com/alo
GNU gdb (GDB) 8.1.1
...
Reading symbols from ./lv2bm...done.
(gdb) run

The result does not give me a clue:

Starting program: /home/jakob/Downloads/github/lv2bm/lv2bm --full-test http://devcurmudgeon.com/alo
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
*** stack smashing detected ***: <unknown> terminated

Program received signal SIGABRT, Aborted.
0x00007ffff70c3d7f in raise () from /usr/lib/libc.so.6

Exit with CTRL-D.

There is another tool to test LV2 plugins: Torture tester.

$ git clone git@github.com:cth103/plugin-torture.git
$ cd plugin-torture
$ make

Again I run it with gdb:

$ gdb --args ./plugin-torture -d -a -e --lv2 -p ~/.lv2/alo.lv2/manifest.ttl
...
(gdb) run
...
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7fca5af in run (instance=0x555555896d00, n_samples=1024) at alo.c:450
450          !lv2_atom_sequence_is_end(&in->body, in->atom.size, ev);

Looking at alo.c, there could be some problem with iterating this sequence in the for loop. The first thing that comes to my mind is "there is some FOR_EACH macro in lilv. Could that help?". But I stop here for now.

devcurmudgeon commented 6 years ago

OK, I believe I've fixed the 'stack smashing' now (in master) - @jkbd would you mind re-testing, please?

I think it would be worthwhile to have some guidance for testing/debuggin like what you wrote above, on the wiki

jkbd commented 6 years ago

LILV_FOREACH does not fit here. Also LV2_ATOM_SEQUENCE_FOREACH does not help. Maybe the eg-metro.lv2 plugin has the same problem?

jkbd commented 6 years ago

Oh, I didn't notice your update. Testing:

$ gdb --args ./lv2bm --full-test http://devcurmudgeon.com/alo
...
Plugin: http://devcurmudgeon.com/alo, Input signal: Sine Wave
    TestName  TotalTime(s)   AvrTime(s)  JackLoad(%)
   MinValues    0.00193801   0.00000517     0.387603
   DefValues    0.00220128   0.00000587     0.440256
   MaxValues    0.00243232   0.00000649     0.486464
  BestResult    0.00186795   0.00000498     0.373590
 WorstResult    0.00398386   0.00001062     0.796773
[Inferior 1 (process 5735) exited normally]

Looks good. But somehow:

$ gdb --args ./plugin-torture -d -a -e --lv2 -p ~/.lv2/alo.lv2/manifest.ttl
...
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7fca5af in run (instance=0x555555896d00, n_samples=1024) at alo.c:450
450          !lv2_atom_sequence_is_end(&in->body, in->atom.size, ev);

I'm puzzled.

devcurmudgeon commented 6 years ago

Me too :-)

jkbd commented 6 years ago

Sure I will add this description to the MOD Wiki later.

jkbd commented 6 years ago

Testing eg-metro

$ gdb --args ./plugin-torture -e -a -d --lv2 -p /usr/lib/lv2/eg-metro.lv2/manifest.ttl

also gives a segmentation fault. I can't build it for debugging now to see if it is crashing in the very same loop.

devcurmudgeon commented 6 years ago

ok, at that point maybe we can say that this is not an ALO issue, and accept the original pull request? or am i being too optimistic? :-)

jkbd commented 6 years ago

I will write you about the pull request at the beginning of the next week. I think, we want to have the version as a commit-hash instead of master in the *.mk file and we want a MOD-GUI. The new description for using mod-sdk will be ready soon and we can test it with ALO. Please be patient, this will not be much work from here.

devcurmudgeon commented 6 years ago

OK, fair enough. I'm closing this issue, though, since the segfault and stack smashing are fixed.