Cabbage Logo
Back to Cabbage Site

Cabbage crash - cabbageGet and strcpyk and long strings

I came across some peculiar behaviour. The example below is taken out of context, anyhow there are two buttons, “Browse” and “Load”, and I am simply copying a string, triggered by pushing “Load”. If I have cabbageGet in the code and I am copying a longer string with strcpyk then Cabbage crashes (upon a few clicks on the “Load” button). However, there seems to be no issue if I comment the cabbageGet part or if I copy shorter names (underscore seem to be accepted well). See comments in the example below. :face_with_raised_eyebrow:

<Cabbage>
form caption("test load") size(330, 290) pluginId("tl01") colour(0, 0, 0) guiMode("queue")
button bounds(24, 24, 70, 14)  channel("Load") text("LOAD", "LOAD") automatable(0) corners(3) latched(0)  colour:0(255, 255, 0, 80) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255) fontColour:1(160, 0, 0, 255)
filebutton bounds(24, 50, 70, 14)  channel("Browse")  text("BROWSE", "BROWSE") corners(3) colour:0(255, 255, 0, 80) colour:1(255, 255, 0, 255) fontColour:0(255, 255, 0, 255)
</Cabbage>

<CsoundSynthesizer>
<CsOptions>
-n -d -m0d -+rtmidi=NULL 
</CsOptions>
<CsInstruments>

ksmps   = 32  
instr 1

S_LoadFileName cabbageGet "Browse" ; if this line is commented, no issue
;SDefaultName = "FileName.txt" ; OK?
;SDefaultName = "A_FileName.txt" ; OK?
SDefaultName = "SomethingLonger_FileName.txt" ; Not OK!

if trigger(cabbageGetValue:k("Load"), .5, 0) == 1 then
    S_LoadFileName strcpyk SDefaultName
endif

endin

</CsInstruments>
<CsScore>
f0 z
i 1 0 -1
</CsScore>
</CsoundSynthesizer>

I’m not seeing any issues here when I test this with the latest build - 2.7.10 What version are you using?

I tested with 2.7.8. Have you tried pushing “Load” button several times?

I’m all over the Load button. Cannot get it to crash. Can you try with the latest build, we’re already on 2.7.11. No point in dwelling on the past :rofl:

Still crashing on MacOS 10.14.6 - Cabbage 2.7.11

Ok, if I hit load before hitting anything else I can make it crash :+1: I didn’t think of this before…

What is this line supposed to do exactly? What is it you expect to get from this:

S_LoadFileName cabbageGet "Browse" ; if this line is commented, no issue

Replace it with a cabbageGetValue and you no longer get a crash. I will however try to prevent that crash from happening…

Ah, I think that was it! That line was there from a brother context and while I did notice that enabled the “crashing feature”, I didn’t notice that I should have used cabbageGetValue. I think I am still building up my muscle memory with all the cabbageGet-s :slight_smile: Thanks!

1 Like

I just triggered a new build now. You should no longer get a crash. :+1:

Super! Faster then I can type! But how is that cabbageGet actually worked - with shorter names?

Oh because there was an actual bug in that opcode! Which you managed to accidentally find :clap: