Csound Csound-dev Csound-tekno Search About

[Csnd-dev] Possible bug in init time array output UDO

Date2025-12-07 23:33
FromRichard Knight
Subject[Csnd-dev] Possible bug in init time array output UDO
Hi
I'm using the latest commit and noticed that a UDO defined like the 
following causes a segfault with "free(): invalid pointer"

opcode test1, i[]i, 0
         iout[] fillarray 1, 2, 3
         inum = 123
         xout iout, inum
endop

instr 1
         iout[], inum test1
endin



This only seems to happen if a primitive follows an array (i[]i and 
ii[]i do not work, but ii[] and i[]i[] work OK), and only occurs with 
init parameters, the same at k-rate works OK.
Shall I raise this as a bug on github?

thanks
RK

Date2025-12-08 06:45
FromHlöðver Sigurðsson
SubjectRe: [Csnd-dev] Possible bug in init time array output UDO
this could have (maybe) been a change I made that broke this. I'll take a look at this today, and prepare a test-case to catch this.

On Mon, 8 Dec 2025 at 01:33, Richard Knight <richard@1bpm.net> wrote:
Hi
I'm using the latest commit and noticed that a UDO defined like the
following causes a segfault with "free(): invalid pointer"

opcode test1, i[]i, 0
         iout[] fillarray 1, 2, 3
         inum = 123
         xout iout, inum
endop

instr 1
         iout[], inum test1
endin



This only seems to happen if a primitive follows an array (i[]i and
ii[]i do not work, but ii[] and i[]i[] work OK), and only occurs with
init parameters, the same at k-rate works OK.
Shall I raise this as a bug on github?

thanks
RK

Date2025-12-08 08:14
Fromvlz
SubjectRe: [Csnd-dev] Possible bug in init time array output UDO
yes, there is a bug we have fixed in a PR which I think is related.

best
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 7 Dec 2025, at 23:34, Richard Knight  wrote:
> 
> Hi
> I'm using the latest commit and noticed that a UDO defined like the following causes a segfault with "free(): invalid pointer"
> 
> opcode test1, i[]i, 0
>        iout[] fillarray 1, 2, 3
>        inum = 123
>        xout iout, inum
> endop
> 
> instr 1
>        iout[], inum test1
> endin
> 
> 
> 
> This only seems to happen if a primitive follows an array (i[]i and ii[]i do not work, but ii[] and i[]i[] work OK), and only occurs with init parameters, the same at k-rate works OK.
> Shall I raise this as a bug on github?
> 
> thanks
> RK

Date2025-12-08 11:25
FromRichard Knight
SubjectRe: [Csnd-dev] Possible bug in init time array output UDO
Thank you!

On 2025-12-08 08:14, vlz wrote:
> yes, there is a bug we have fixed in a PR which I think is related.
> 
> best
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 
>> On 7 Dec 2025, at 23:34, Richard Knight  wrote:
>> 
>> Hi
>> I'm using the latest commit and noticed that a UDO defined like the 
>> following causes a segfault with "free(): invalid pointer"
>> 
>> opcode test1, i[]i, 0
>>        iout[] fillarray 1, 2, 3
>>        inum = 123
>>        xout iout, inum
>> endop
>> 
>> instr 1
>>        iout[], inum test1
>> endin
>> 
>> 
>> 
>> This only seems to happen if a primitive follows an array (i[]i and 
>> ii[]i do not work, but ii[] and i[]i[] work OK), and only occurs with 
>> init parameters, the same at k-rate works OK.
>> Shall I raise this as a bug on github?
>> 
>> thanks
>> RK