[Csnd-dev] is this a bug?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd-dev] is this a bug?

joachim-3
this code prevents kIndx from increasing more than 5:

instr 1
kArr[] init 5
kIndx = 0
while kIndx < 10 do ;try kIndx < 5 instead
  kArr[kIndx] = 1
  printk2 kIndx
  kIndx += 1
od
turnoff
endin


csound here looks for the array length and holds kIndx to length-1.

i would expect that kIndx can increment nevertheless but the internal
array index is limited to the maximum of length-1.

am i wrong?  is this as expected?


best -
        joachim
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd-dev] is this a bug?

Mauro Giubileo

I don't know how Csound manages internally these situations, but normally I would expect that you'll have a segmentation fault, being that you have declared an array of 5 elements, but then you try to access to elements beyond the allocated size for the array...

Regards,
Mauro

Il 2018-10-03 14:18 joachim heintz ha scritto:

this code prevents kIndx from increasing more than 5:

instr 1
kArr[] init 5
kIndx = 0
while kIndx < 10 do ;try kIndx < 5 instead
 kArr[kIndx] = 1
 printk2 kIndx
 kIndx += 1
od
turnoff
endin


csound here looks for the array length and holds kIndx to length-1.

i would expect that kIndx can increment nevertheless but the internal array index is limited to the maximum of length-1.

am i wrong?  is this as expected?


best -
    joachim
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd-dev] is this a bug?

joachim-3
to prevent this segfault, csound has a boundary check for arrays and tables.

but should the boundary check really affect the variable, or only the
reference in the array?

obviously csound makes no difference here ...



On 03/10/18 14:38, Mauro Giubileo wrote:

> I don't know how Csound manages internally these situations, but
> normally I would expect that you'll have a segmentation fault, being
> that you have declared an array of 5 elements, but then you try to
> access to elements beyond the allocated size for the array...
>
> Regards,
> Mauro
>
> Il 2018-10-03 14:18 joachim heintz ha scritto:
>
>> this code prevents kIndx from increasing more than 5:
>>
>> instr 1
>> kArr[] init 5
>> kIndx = 0
>> while kIndx < 10 do ;try kIndx < 5 instead
>>  kArr[kIndx] = 1
>>  printk2 kIndx
>>  kIndx += 1
>> od
>> turnoff
>> endin
>>
>>
>> csound here looks for the array length and holds kIndx to length-1.
>>
>> i would expect that kIndx can increment nevertheless but the internal
>> array index is limited to the maximum of length-1.
>>
>> am i wrong?  is this as expected?
>>
>>
>> best -
>>     joachim
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd-dev] is this a bug?

Victor Lazzarini-2
In reply to this post by joachim-3
That’s how the code was written. The opcode returns an error code and the rest of the instrument stops executing for
the rest of the k-cycle. Whether that is how it should be or not, I don’t know. If we stuck a PerfError() then the instrument
would be stopped. Not sure again if it is too much.

Not signalling is an error might possibly be misleading too.

 
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 3 Oct 2018, at 13:18, joachim heintz <[hidden email]> wrote:
>
> this code prevents kIndx from increasing more than 5:
>
> instr 1
> kArr[] init 5
> kIndx = 0
> while kIndx < 10 do ;try kIndx < 5 instead
> kArr[kIndx] = 1
> printk2 kIndx
> kIndx += 1
> od
> turnoff
> endin
>
>
> csound here looks for the array length and holds kIndx to length-1.
>
> i would expect that kIndx can increment nevertheless but the internal array index is limited to the maximum of length-1.
>
> am i wrong?  is this as expected?
>
>
> best -
> joachim

Reply | Threaded
Open this post in threaded view
|

Re: [Csnd-dev] is this a bug?

jpff
In reply to this post by joachim-3
I would epect an init error when kIndx is 5 so the instruent would stop.
What happens?


On Wed, 3 Oct 2018, joachim heintz wrote:

> this code prevents kIndx from increasing more than 5:
>
> instr 1
> kArr[] init 5
> kIndx = 0
> while kIndx < 10 do ;try kIndx < 5 instead
> kArr[kIndx] = 1
> printk2 kIndx
> kIndx += 1
> od
> turnoff
> endin
>
>
> csound here looks for the array length and holds kIndx to length-1.
>
> i would expect that kIndx can increment nevertheless but the internal array
> index is limited to the maximum of length-1.
>
> am i wrong?  is this as expected?
>
>
> best -
> joachim
>
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd-dev] is this a bug?

jpff
Sirry, perf error.


On Wed, 3 Oct 2018, jpff wrote:

> I would epect an init error when kIndx is 5 so the instruent would stop. What
> happens?
>
>
> On Wed, 3 Oct 2018, joachim heintz wrote:
>
>> this code prevents kIndx from increasing more than 5:
>>
>> instr 1
>> kArr[] init 5
>> kIndx = 0
>> while kIndx < 10 do ;try kIndx < 5 instead
>> kArr[kIndx] = 1
>> printk2 kIndx
>> kIndx += 1
>> od
>> turnoff
>> endin
>>
>>
>> csound here looks for the array length and holds kIndx to length-1.
>>
>> i would expect that kIndx can increment nevertheless but the internal array
>> index is limited to the maximum of length-1.
>>
>> am i wrong?  is this as expected?
>>
>>
>> best -
>> joachim
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd-dev] is this a bug?

Victor Lazzarini-2
The code returns NOTOK after printing the warning.
========================
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 3 Oct 2018, at 14:27, jpff <[hidden email]> wrote:
>
> Sirry, perf error.
>
>
> On Wed, 3 Oct 2018, jpff wrote:
>
>> I would epect an init error when kIndx is 5 so the instruent would stop. What happens?
>>
>>
>> On Wed, 3 Oct 2018, joachim heintz wrote:
>>
>>> this code prevents kIndx from increasing more than 5:
>>> instr 1
>>> kArr[] init 5
>>> kIndx = 0
>>> while kIndx < 10 do ;try kIndx < 5 instead
>>> kArr[kIndx] = 1
>>> printk2 kIndx
>>> kIndx += 1
>>> od
>>> turnoff
>>> endin
>>> csound here looks for the array length and holds kIndx to length-1.
>>> i would expect that kIndx can increment nevertheless but the internal array index is limited to the maximum of length-1.
>>> am i wrong?  is this as expected?
>>> best -
>>> joachim
>>
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd-dev] is this a bug?

joachim-3
in my example code, it never reaches the "turnoff" line.



On 03/10/18 15:33, Victor Lazzarini wrote:

> The code returns NOTOK after printing the warning.
> ========================
> 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 3 Oct 2018, at 14:27, jpff <[hidden email]> wrote:
>>
>> Sirry, perf error.
>>
>>
>> On Wed, 3 Oct 2018, jpff wrote:
>>
>>> I would epect an init error when kIndx is 5 so the instruent would stop. What happens?
>>>
>>>
>>> On Wed, 3 Oct 2018, joachim heintz wrote:
>>>
>>>> this code prevents kIndx from increasing more than 5:
>>>> instr 1
>>>> kArr[] init 5
>>>> kIndx = 0
>>>> while kIndx < 10 do ;try kIndx < 5 instead
>>>> kArr[kIndx] = 1
>>>> printk2 kIndx
>>>> kIndx += 1
>>>> od
>>>> turnoff
>>>> endin
>>>> csound here looks for the array length and holds kIndx to length-1.
>>>> i would expect that kIndx can increment nevertheless but the internal array index is limited to the maximum of length-1.
>>>> am i wrong?  is this as expected?
>>>> best -
>>>> joachim
>>>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd-dev] is this a bug?

Victor Lazzarini-2
It wouldn't. As I said it bails out after the warning is printed and begins again at the top for the next kcycle.

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

> On 3 Oct 2018, at 14:55, joachim heintz <[hidden email]> wrote:
>
> in my example code, it never reaches the "turnoff" line.
>
>
>
>> On 03/10/18 15:33, Victor Lazzarini wrote:
>> The code returns NOTOK after printing the warning.
>> ========================
>> 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 3 Oct 2018, at 14:27, jpff <[hidden email]> wrote:
>>>
>>> Sirry, perf error.
>>>
>>>
>>>> On Wed, 3 Oct 2018, jpff wrote:
>>>>
>>>> I would epect an init error when kIndx is 5 so the instruent would stop. What happens?
>>>>
>>>>
>>>>> On Wed, 3 Oct 2018, joachim heintz wrote:
>>>>>
>>>>> this code prevents kIndx from increasing more than 5:
>>>>> instr 1
>>>>> kArr[] init 5
>>>>> kIndx = 0
>>>>> while kIndx < 10 do ;try kIndx < 5 instead
>>>>> kArr[kIndx] = 1
>>>>> printk2 kIndx
>>>>> kIndx += 1
>>>>> od
>>>>> turnoff
>>>>> endin
>>>>> csound here looks for the array length and holds kIndx to length-1.
>>>>> i would expect that kIndx can increment nevertheless but the internal array index is limited to the maximum of length-1.
>>>>> am i wrong?  is this as expected?
>>>>> best -
>>>>>    joachim
>>>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd-dev] is this a bug?

Mauro Giubileo
In reply to this post by Victor Lazzarini-2

Personally, in these situations I would prefer that Csound stop the performance with a straightforward error message, instead of jumping the k-cycle and causing many misleading behaviours.

Regards,
Mauro


Il 2018-10-03 15:21 Victor Lazzarini ha scritto:

That's how the code was written. The opcode returns an error code and the rest of the instrument stops executing for
the rest of the k-cycle. Whether that is how it should be or not, I don't know. If we stuck a PerfError() then the instrument
would be stopped. Not sure again if it is too much.

Not signalling is an error might possibly be misleading too.

 
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 3 Oct 2018, at 13:18, joachim heintz <[hidden email]> wrote:

this code prevents kIndx from increasing more than 5:

instr 1
kArr[] init 5
kIndx = 0
while kIndx < 10 do ;try kIndx < 5 instead
kArr[kIndx] = 1
printk2 kIndx
kIndx += 1
od
turnoff
endin


csound here looks for the array length and holds kIndx to length-1.

i would expect that kIndx can increment nevertheless but the internal array index is limited to the maximum of length-1.

am i wrong?  is this as expected?


best -
    joachim