[Csnd] csound segfaults on numeric pfield when expecting string argument
Date | 2022-03-15 23:16 |
From | Iain Duncan |
Subject | [Csnd] csound segfaults on numeric pfield when expecting string argument |
Attachments | cs-out-msg.csd |
Hi everyone, I've gotten csound6~ in Max handling events with strings in them nicely now, so that I can dynamically create control processes that write to kchannels. However, if one sends a numeric pfield to an instrument that is expecting a string pfield, it segfaults. The other way around is handled gracefully: if I send a string arg to a regular instrument where it expects a number, I get a NaN out and no crash.
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
This is a bit of a show stopper for my use case, as I want to make sure there is no chance of tanking Max from an illformed input score event. If need be I'm willing to dive into the main source to fix it, but wanted to float this here first to find out if there are workarounds, or what the protocol for fixing something like this should be (as I have never contributed to core). My example csd is attached thanks iain |
Date | 2022-03-15 23:33 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] csound segfaults on numeric pfield when expecting string argument |
Attachments | cs-out-msg.csd |
I'd say open a ticket and we can look at it. Ideally we would like an example of the fault that can be reproduced with a simple CSD running straight into Csound (i.e. not specific to a given host or frontend).
Prof. Victor Lazzarini
Maynooth University
Ireland
On 15 Mar 2022, at 23:18, Iain Duncan <iainduncanlists@gmail.com> wrote:
|
Date | 2022-03-15 23:35 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] csound segfaults on numeric pfield when expecting string argument |
Attachments | cs-out-msg.csd |
btw, looking at your CSD the issue seems to be with strget. Prof. Victor Lazzarini
Maynooth University
Ireland
On 15 Mar 2022, at 23:18, Iain Duncan <iainduncanlists@gmail.com> wrote:
|
Date | 2022-03-15 23:58 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] csound segfaults on numeric pfield when expecting string argument |
Attachments | cs-out-msg.csd |
I am not at a computer now, but looking at strget, it should return an empty string if given a numeric argument that does not correspond to a strset string index. So that is something to check first; if it's an empty string then it's predicted behaviour.
Then attention should turn to chnset, to see if it is crashing on an empty channel name.
Prof. Victor Lazzarini
Maynooth University
Ireland
On 15 Mar 2022, at 23:35, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
|
Date | 2022-03-16 00:24 |
From | Iain Duncan |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] csound segfaults on numeric pfield when expecting string argument |
Attachments | string-chan-bug.csd |
Hi Victor, thanks for answering these. I have attached a testing csd. You are correct, it is chnset crashing on an empty string. This happens if I pass an empty string as an arg, or through a pfield using strget, or by having the empty string come from the number. Is there an alternative way to safely get a string from a pfield that will not result in an empty string? (ie, it could become "99" for the channel name or something, which would hopefully not crash?) And for opening a ticket, is that on github, or? thanks iain On Tue, Mar 15, 2022 at 4:58 PM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
|
Date | 2022-03-16 00:24 |
From | Iain Duncan |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] csound segfaults on numeric pfield when expecting string argument |
sorry, forgot to mention I used the test csd with command line csound outside of Max. iain On Tue, Mar 15, 2022 at 5:24 PM Iain Duncan <iainduncanlists@gmail.com> wrote:
|
Date | 2022-03-16 00:37 |
From | Eduardo Moguillansky |
Subject | Re: [Csnd] csound segfaults on numeric pfield when expecting string argument |
Try this: instr xx S_chan strget p4 if strlen(S_chan) == 0 then prints "Not a string\n" turnoff endif klfo lfo 1, 1 chnset klfo, S_chan endin It would be nice if csound would throw
an error if chnset is called with an empty channel.
On 16.03.22 00:16, Iain Duncan wrote:
|
Date | 2022-03-16 00:46 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] csound segfaults on numeric pfield when expecting string argument |
Attachments | string-chan-bug.csd |
chnget should nor crash, so that needs to be fixed. We can't change the behaviour of strget, I'm afraid.
You can use strcmp to check for an empty string to avoid the crash for now.
Prof. Victor Lazzarini
Maynooth University
Ireland
On 16 Mar 2022, at 00:25, Iain Duncan <iainduncanlists@gmail.com> wrote:
|
Date | 2022-03-16 00:47 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] csound segfaults on numeric pfield when expecting string argument |
yes, crashing is ugly. Prof. Victor Lazzarini
Maynooth University
Ireland
On 16 Mar 2022, at 00:37, Eduardo Moguillansky <eduardo.moguillansky@gmail.com> wrote:
|
Date | 2022-03-16 09:52 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] csound segfaults on numeric pfield when expecting string argument |
Ok, this is done now. It was only chnset that needed fixing, chnget was fine. In csound6 branch. I did not apply changes yet to develop,
because that whole area needs reviewing anyway.
commit 512984db5dbb637fc53b3a50ff8480dbf715d6a1 (HEAD -> csound6, origin/csound6)
Author: Victor Lazzarini <victor.lazzarini@mu.ie> Date: Wed Mar 16 09:48:56 2022 +0000 fixed crash on channel setting with empty channel name
|
Date | 2022-03-16 14:45 |
From | Iain Duncan |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] csound segfaults on numeric pfield when expecting string argument |
thanks Victor! Does one need to rebuild csound to pick this up or are releases online updated automatically? thanks very much for jumping on it so fast. iain On Wed, Mar 16, 2022 at 2:52 AM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
|
Date | 2022-03-16 14:59 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] csound segfaults on numeric pfield when expecting string argument |
This fix will come out in the next release, unless you build your own Csound, in which case you might try it straight away.
|
Date | 2022-03-16 18:39 |
From | Iain Duncan |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] csound segfaults on numeric pfield when expecting string argument |
ok thanks for the clarification. Will try building! iain On Wed, Mar 16, 2022 at 7:59 AM Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
|
Date | 2022-03-16 23:54 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] Re: [Csnd] csound segfaults on numeric pfield when expecting string argument |
It's pretty straightforward, you only need libsndfile installed (which is easily built from sources).
Then it's just cmake. I have also built my own flex and bison, but I think this may not be needed.
Prof. Victor Lazzarini
Maynooth University
Ireland
On 16 Mar 2022, at 18:40, Iain Duncan <iainduncanlists@gmail.com> wrote:
|