[Csnd-dev] Segfault with UDP
Date | 2017-10-26 21:35 |
From | Hlöðver Sigurðsson |
Subject | [Csnd-dev] Segfault with UDP |
Steps to reproduce
1. Start Csound with `csound -odac --port=6006` (useing dev branch compiled today) 2. Useing Nodejs (Im useing v8.0) send udp messages to the csound instance with this script https://pastebin.com/2GSqXKmP notice `csound command: Segmentation fault` 3. With the same javascript script, delete or comment with semicolons line number 59 (where Chorus opcode is called) and notice that there's no segfault and everything works. 4. Uncomment line 59 and allow it to be, but delete line 63 to 76, and notice that again everything works (and seemingly Chorus had nothing to do with the segfault). I will add that equivalent code works without segfault when running directly from csd file. |
Date | 2017-10-26 21:38 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd-dev] Segfault with UDP |
from gdb, this message is printed Thread 1 "csound" received signal SIGSEGV, Segmentation fault. 0x00007ffff7899b8f in useropcdset () from /usr/local/lib/libcsound64.so.6.0 On 26 October 2017 at 22:35, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
|
Date | 2017-10-26 22:02 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
That’s the UDO init code. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 26 Oct 2017, at 21:38, Hlöðver Sigurðsson |
Date | 2017-10-26 22:23 |
From | Steven Yi |
Subject | Re: [Csnd-dev] Segfault with UDP |
Tested here on Windows with both MinGW and VS builds and both crash in the same place: csound64.dll!useropcdset(CSOUND_ * csound, UOPCODE * p) Line 1255 C Symbols loaded. > csound64.dll!insert(CSOUND_ * csound, int insno, event * newevtp) Line 300 C Symbols loaded. csound64.dll!process_score_event(CSOUND_ * csound, event * evt, int rtEvt) Line 777 C Symbols loaded. csound64.dll!process_rt_event(CSOUND_ * csound, int sensType) Line 873 C Symbols loaded. csound64.dll!sensevents(CSOUND_ * csound) Line 1061 C Symbols loaded. csound64.dll!csoundPerform(CSOUND_ * csound) Line 2147 C Symbols loaded. csound.exe!main(int argc, char * * argv) Line 327 C Symbols loaded. [External Code] Annotated Frame Haven't found a cause for it yet. On Thu, Oct 26, 2017 at 5:02 PM, Victor Lazzarini |
Date | 2017-10-26 22:26 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
I wonder if the whole code is being sent. UDP has a maximum number of characters (MTU), which this might be exceeding. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 26 Oct 2017, at 21:38, Hlöðver Sigurðsson |
Date | 2017-10-26 22:31 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd-dev] Segfault with UDP |
The MTU limit is I think 64 kilobytes. I exceeded that before and got different error Error: send EMSGSIZE but then from the client side. But the code I was sending then was huge. On 26 October 2017 at 23:26, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote: I wonder if the whole code is being sent. UDP has a maximum number of characters (MTU), which this might be exceeding. |
Date | 2017-10-26 22:37 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
What is happening is that the message is broken into two pieces and they get compiled separately and so it doesn’t quite work. There is a problem with large bits of code, which I will try to address. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 26 Oct 2017, at 21:38, Hlöðver Sigurðsson |
Date | 2017-10-26 22:41 |
From | Steven Yi |
Subject | Re: [Csnd-dev] Segfault with UDP |
Attachments | test.csd |
There's something else I'm seeing that might be a part of this: When the program crashes, tp is NULL. instno is 201 (I think that must be assigned to the Chorus UDO). If I modify the orc code to make the mixer instrument 100 instead of 10000, I don't get a crash. If I run the code as a CSD on its own its fine. (Attached) On Thu, Oct 26, 2017 at 5:37 PM, Victor Lazzarini |
Date | 2017-10-26 23:54 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
I was having trouble sending large orcs with nc and so I have added support for longer code or code broken in lines using { and }. Anyway, I seem to be able to reproduce the segfault with chorus ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 26 Oct 2017, at 22:41, Steven Yi |
Date | 2017-10-27 00:00 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
I get 1252 if (!p->ip) { 1253 /* search for already allocated, but not active instance */ 1254 /* if none was found, allocate a new instance */ -> 1255 if (!tp->act_instance) ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 26 Oct 2017, at 22:41, Steven Yi |
Date | 2017-10-27 00:02 |
From | Steven Yi |
Subject | Re: [Csnd-dev] Segfault with UDP |
Yes, we're on the same page as that's exactly where I had the crash with NULL tp. On Thu, Oct 26, 2017 at 7:00 PM, Victor Lazzarini |
Date | 2017-10-27 00:03 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
It seems it can’t find an instrument. If reduce instr 10000 to instr 10 it doesn’t crash anymore. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 27 Oct 2017, at 00:02, Steven Yi |
Date | 2017-10-27 00:11 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
I’ve added an InitError for that case. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 27 Oct 2017, at 00:03, Victor Lazzarini |
Date | 2017-10-27 01:38 |
From | Steven Yi |
Subject | Re: [Csnd-dev] Segfault with UDP |
But there's still a problem here I think. If you run the code on its own outside of the context of UDP (see the test.csd I attached in previous message in this thread) it works just fine. I think it's good to protect against trying to deref tp when it's NULL, but it seems there's still a bug to fix. On Thu, Oct 26, 2017 at 7:11 PM, Victor Lazzarini |
Date | 2017-10-27 06:23 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
yes, there is a bug alright. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland
|
Date | 2017-10-27 09:44 |
From | Steven Yi |
Subject | Re: [Csnd-dev] Segfault with UDP |
Perhaps there is an issue with merging when there is a large instrument number introduced? Thinking there is a difference between first compile pass and latter ones. (Sidenote: in cs7, we should revisit named instruments having numbers assigned, as one can easily assign a numbered instrument after a named one that redefines the assigned number) On Fri, Oct 27, 2017 at 1:23 AM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
|
Date | 2017-10-27 14:01 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
yes, I think it is to do with merging. I have not had a chance to investigate yet. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 27 Oct 2017, at 09:44, Steven Yi |
Date | 2017-10-27 18:32 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
I think I got this now. The insertion of opcodes was happening at the wrong time in the compilation. This only applied to compilations after the first one, so that is why it worked in normal running. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 27 Oct 2017, at 14:01, Victor Lazzarini |
Date | 2017-10-27 21:04 |
From | Steven Yi |
Subject | Re: [Csnd-dev] Segfault with UDP |
Tested here on Windows and it's now working great. (Though, I had to add aL *= 0dbfs and aR *= 0dbfs in instr 1 to hear anything ;) ). Nice find! On Fri, Oct 27, 2017 at 1:32 PM, Victor Lazzarini |
Date | 2017-10-27 22:02 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
Thanks for confirming. The clue was in checking how the first compilation behaved
differently and then I spotted the out-of-order operation.
Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland
|
Date | 2017-10-28 11:33 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd-dev] Segfault with UDP |
confirmed here too, no segfault anymore, works perfectly! Thanks for fixing this so quickly On 27 October 2017 at 23:02, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
|
Date | 2017-10-28 13:39 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd-dev] Segfault with UDP |
I'm still getting segfaults, now with tables, I'm trying to create a reproduceable example, but what I'm getting is this INIT ERROR in instr 27 (opcode Flanger_stereo): Invalid ftable no. 0.000000 amod oscili.a kdepth krate giParabola 0 INIT ERROR in instr 27 (opcode Flanger_stereo): Invalid ftable no. 0.000000 amod oscili.a kdepth krate giSine 0 INIT ERROR in instr 27 (opcode Flanger_stereo): Invalid ftable no. 0.000000 amod oscili.a kdepth krate giTriangle 0 csound command: Segmentation fault On 28 October 2017 at 12:33, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
|
Date | 2017-10-28 14:01 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd-dev] Segfault with UDP |
Also this pops up randomly INIT ERROR in instr 27 (opcode Chorus): Min and max the same aChoL ntrpol.a aChoL aCho1 iwidth 0 1 INIT ERROR in instr 27 (opcode Chorus): Min and max the same aChoR ntrpol.a aChoR aCho2 iwidth 0 1 INIT ERROR in instr 27 (opcode Chorus): Min and max the same aoutL ntrpol.a #a29 #a30 iwet 0 1 INIT ERROR in instr 27 (opcode Chorus): Min and max the same aoutR ntrpol.a #a31 #a32 iwet 0 1 csound command: Segmentation fault maybe due to iwidth and iwet are the same value here? aChoL ntrpol aChoL,aCho1,iwidth aChoR ntrpol aChoR,aCho2,iwidth aoutL ntrpol ainL*0.6, aChoL*0.6, iwet aoutR ntrpol ainR*0.6, aChoR*0.6, iwet Just thinking out loud, will post reproduceable example when I'm able to make one. On 28 October 2017 at 14:39, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
|
Date | 2017-10-28 15:10 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd-dev] Segfault with UDP |
With the Chorus instrument I'm getting Thread 1 "csound" received signal SIGSEGV, Segmentation fault. 0x00007ffff789a37d in useropcdset () But flanger it's: new alloc for instr 27: INIT ERROR in instr 27 (opcode Flanger_stereo): Invalid ftable no. 0.000000 amod oscili.a kdepth krate giParabola 0 INIT ERROR in instr 27 (opcode Flanger_stereo): Invalid ftable no. 0.000000 amod oscili.a kdepth krate giSine 0 INIT ERROR in instr 27 (opcode Flanger_stereo): Invalid ftable no. 0.000000 amod oscili.a kdepth krate giTriangle 0 Thread 1 "csound" received signal SIGSEGV, Segmentation fault. 0x00007ffff78a10b4 in mfree () from /usr/local/lib/libcsound64.so.6.0 Still unable to reproduce it, could be from these ftgen statements (there are almost 300 samples) gi_ ftgen 1000,0,0,1,"/home/hlolli/.samples/stl-texture/014.wav",0,0,0 gi_ ftgen 1001,0,0,1,"/home/hlolli/.samples/stl-texture/stl_texture_1.wav",0,0,0 gi_ ftgen 1002,0,0,1,"/home/hlolli/.samples/stl-texture/stl_texture_10.wav",0,0,0 gi_ ftgen 1003,0,0,1,"/home/hlolli/.samples/stl-texture/stl_texture_11.wav",0,0,0 gi_ ftgen 1004,0,0,1,"/home/hlolli/.samples/stl-texture/stl_texture_12.wav",0,0,0 On 28 October 2017 at 15:01, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
|
Date | 2017-10-28 16:30 |
From | Victor Lazzarini |
Subject | Re: [Csnd-dev] Segfault with UDP |
best send us the code Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland
|
Date | 2017-10-28 20:19 |
From | jpff |
Subject | Re: [Csnd-dev] Segfault with UDP |
On Sat, 28 Oct 2017, Hlöðver Sigurðsson wrote: > With the Chorus instrument I'm getting > > Thread 1 "csound" received signal SIGSEGV, Segmentation fault. > 0x00007ffff789a37d in useropcdset () > > But flanger it's: > > new alloc for instr 27: > INIT ERROR in instr 27 (opcode Flanger_stereo): Invalid ftable no. 0.000000 > amod oscili.a kdepth krate giParabola 0 > INIT ERROR in instr 27 (opcode Flanger_stereo): Invalid ftable no. 0.000000 > amod oscili.a kdepth krate giSine 0 > INIT ERROR in instr 27 (opcode Flanger_stereo): Invalid ftable no. 0.000000 > amod oscili.a kdepth krate giTriangle 0 The obvious explanation is that giParabola and similar have had their values zapped to zero, or you assigned something like that. Are these set in instr0? If so do you get this problem if they are set in a declared instrument? resetting values to zero would also explain the max/mi issue |
Date | 2017-10-29 12:29 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd-dev] Segfault with UDP |
Ok good news, I declare these problems solved. I made a mistake, which is when I thought I was setting timeout between large blocks of orchestra code, then what was really happening, the thousands of lines of orchestra code was being fired at the same time, and some tables were being defined later on, it was basically a large cocktail of synchronous events to an async client. It seems very stable when I add delay between every orchestra code block on startup. On 28 October 2017 at 21:19, jpff <jpff@codemist.co.uk> wrote:
|