Csound Csound-dev Csound-tekno Search About

[Cs-dev] more string questions..

Date2014-02-08 16:44
FromRory Walsh
Subject[Cs-dev] more string questions..
The following segfaults Csound(GetStringChannel()). Am I doing something wrong?

int main(int argc, char *argv[])
{
   /*Create an instance of Csound*/
   Csound* csound = new Csound ;
   char csd[] = "example1.csd";
   csound->Compile(csd);
   char* msg;
   char channel[] = "string";
   csound->PerformKsmps();
   csound->GetStringChannel("string", msg);
   csound->Perform();
   /*delete instance of csound*/
   delete csound;
}

I am running a performKsmps first to make sure the channel exists.
(btw, when does the first init-pass take place, is it during compile?)

My Csound instrument looks like this:

chn_S "string", 3
instr 1
chnset "test", "string"
endin

When I run similar code from Cabbage I get the following problem:

0  0x00007ffff6ef6a50  pthread_spin_lock
../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
1  0x00007ffff6974d3e  csoundGetStringChannel
/home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
2  0x00000000004e1ec9  Csound::GetStringChannel
/usr/local/include/csound/csound.hpp  760

In Cabbage I only call that function as the end of a k cycle.

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-08 17:13
FromVictor Lazzarini
SubjectRe: [Cs-dev] more string questions..
msg does not have any memory, I guess that’s why it segfaults. Try using
msg[256] or allocating it dynamically.

On 8 Feb 2014, at 16:44, Rory Walsh  wrote:

> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
> 
> int main(int argc, char *argv[])
> {
>   /*Create an instance of Csound*/
>   Csound* csound = new Csound ;
>   char csd[] = "example1.csd";
>   csound->Compile(csd);
>   char* msg;
>   char channel[] = "string";
>   csound->PerformKsmps();
>   csound->GetStringChannel("string", msg);
>   csound->Perform();
>   /*delete instance of csound*/
>   delete csound;
> }
> 
> I am running a performKsmps first to make sure the channel exists.
> (btw, when does the first init-pass take place, is it during compile?)
> 
> My Csound instrument looks like this:
> 
> chn_S "string", 3
> instr 1
> chnset "test", "string"
> endin
> 
> When I run similar code from Cabbage I get the following problem:
> 
> 0  0x00007ffff6ef6a50  pthread_spin_lock
> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
> 1  0x00007ffff6974d3e  csoundGetStringChannel
> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
> 2  0x00000000004e1ec9  Csound::GetStringChannel
> /usr/local/include/csound/csound.hpp  760
> 
> In Cabbage I only call that function as the end of a k cycle.
> 
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-08 17:25
FromRory Walsh
SubjectRe: [Cs-dev] more string questions..
Makes sense, but I still get a segfault char msg[256]?

#0  __strcpy_sse2_unaligned ()
    at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:297
#1  0x00007ffff7a6cd56 in csoundGetStringChannel (csound=0x609030,
    name=0x40574b "string", string=0x7fffffffdf10 "")
    at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:174
#2  0x00000000004052a1 in Csound::GetStringChannel (this=0x609010,
    name=0x40574b "string", string=0x7fffffffdf10 "")
    at /usr/local/include/csound/csound.hpp:760
#3  0x00000000004037c2 in main (argc=1, argv=0x7fffffffe118) at test.cpp:17

On 8 February 2014 17:13, Victor Lazzarini  wrote:
> msg does not have any memory, I guess that's why it segfaults. Try using
> msg[256] or allocating it dynamically.
>
> On 8 Feb 2014, at 16:44, Rory Walsh  wrote:
>
>> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
>>
>> int main(int argc, char *argv[])
>> {
>>   /*Create an instance of Csound*/
>>   Csound* csound = new Csound ;
>>   char csd[] = "example1.csd";
>>   csound->Compile(csd);
>>   char* msg;
>>   char channel[] = "string";
>>   csound->PerformKsmps();
>>   csound->GetStringChannel("string", msg);
>>   csound->Perform();
>>   /*delete instance of csound*/
>>   delete csound;
>> }
>>
>> I am running a performKsmps first to make sure the channel exists.
>> (btw, when does the first init-pass take place, is it during compile?)
>>
>> My Csound instrument looks like this:
>>
>> chn_S "string", 3
>> instr 1
>> chnset "test", "string"
>> endin
>>
>> When I run similar code from Cabbage I get the following problem:
>>
>> 0  0x00007ffff6ef6a50  pthread_spin_lock
>> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
>> 1  0x00007ffff6974d3e  csoundGetStringChannel
>> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
>> 2  0x00000000004e1ec9  Csound::GetStringChannel
>> /usr/local/include/csound/csound.hpp  760
>>
>> In Cabbage I only call that function as the end of a k cycle.
>>
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-08 17:51
FromVictor Lazzarini
SubjectRe: [Cs-dev] more string questions..
and the code?
On 8 Feb 2014, at 17:25, Rory Walsh  wrote:

> Makes sense, but I still get a segfault char msg[256]?
> 
> #0  __strcpy_sse2_unaligned ()
>    at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:297
> #1  0x00007ffff7a6cd56 in csoundGetStringChannel (csound=0x609030,
>    name=0x40574b "string", string=0x7fffffffdf10 "")
>    at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:174
> #2  0x00000000004052a1 in Csound::GetStringChannel (this=0x609010,
>    name=0x40574b "string", string=0x7fffffffdf10 "")
>    at /usr/local/include/csound/csound.hpp:760
> #3  0x00000000004037c2 in main (argc=1, argv=0x7fffffffe118) at test.cpp:17
> 
> On 8 February 2014 17:13, Victor Lazzarini  wrote:
>> msg does not have any memory, I guess that's why it segfaults. Try using
>> msg[256] or allocating it dynamically.
>> 
>> On 8 Feb 2014, at 16:44, Rory Walsh  wrote:
>> 
>>> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
>>> 
>>> int main(int argc, char *argv[])
>>> {
>>>  /*Create an instance of Csound*/
>>>  Csound* csound = new Csound ;
>>>  char csd[] = "example1.csd";
>>>  csound->Compile(csd);
>>>  char* msg;
>>>  char channel[] = "string";
>>>  csound->PerformKsmps();
>>>  csound->GetStringChannel("string", msg);
>>>  csound->Perform();
>>>  /*delete instance of csound*/
>>>  delete csound;
>>> }
>>> 
>>> I am running a performKsmps first to make sure the channel exists.
>>> (btw, when does the first init-pass take place, is it during compile?)
>>> 
>>> My Csound instrument looks like this:
>>> 
>>> chn_S "string", 3
>>> instr 1
>>> chnset "test", "string"
>>> endin
>>> 
>>> When I run similar code from Cabbage I get the following problem:
>>> 
>>> 0  0x00007ffff6ef6a50  pthread_spin_lock
>>> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
>>> 1  0x00007ffff6974d3e  csoundGetStringChannel
>>> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
>>> 2  0x00000000004e1ec9  Csound::GetStringChannel
>>> /usr/local/include/csound/csound.hpp  760
>>> 
>>> In Cabbage I only call that function as the end of a k cycle.
>>> 
>>> ------------------------------------------------------------------------------
>>> Managing the Performance of Cloud-Based Applications
>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>> Read the Whitepaper.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> 
>> 
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-08 18:42
FromRory Walsh
SubjectRe: [Cs-dev] more string questions..
Ok, it seems that I only get the segfault if I try to call
GetStringChannel() before a call to performKsmps. When is the first
init-pass done? The problem I have in Cabbage persists. It takes me to
the following function and seg faults at the call to csoundSpinLock()?
I'm on Linux btw.

void csoundGetStringChannel(CSOUND *csound, const char *name, char *string)
{
    MYFLT  *pstring;
    if (csoundGetChannelPtr(csound, &pstring, name,
                           CSOUND_STRING_CHANNEL | CSOUND_OUTPUT_CHANNEL)
            == CSOUND_SUCCESS){
      int *lock = csoundGetChannelLock(csound, (char*) name);
      csoundSpinLock(lock);
      strcpy(string, ((STRINGDAT *) pstring)->data);
      csoundSpinUnLock(lock);
    }
}

On 8 February 2014 17:51, Victor Lazzarini  wrote:
> and the code?
> On 8 Feb 2014, at 17:25, Rory Walsh  wrote:
>
>> Makes sense, but I still get a segfault char msg[256]?
>>
>> #0  __strcpy_sse2_unaligned ()
>>    at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:297
>> #1  0x00007ffff7a6cd56 in csoundGetStringChannel (csound=0x609030,
>>    name=0x40574b "string", string=0x7fffffffdf10 "")
>>    at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:174
>> #2  0x00000000004052a1 in Csound::GetStringChannel (this=0x609010,
>>    name=0x40574b "string", string=0x7fffffffdf10 "")
>>    at /usr/local/include/csound/csound.hpp:760
>> #3  0x00000000004037c2 in main (argc=1, argv=0x7fffffffe118) at test.cpp:17
>>
>> On 8 February 2014 17:13, Victor Lazzarini  wrote:
>>> msg does not have any memory, I guess that's why it segfaults. Try using
>>> msg[256] or allocating it dynamically.
>>>
>>> On 8 Feb 2014, at 16:44, Rory Walsh  wrote:
>>>
>>>> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
>>>>
>>>> int main(int argc, char *argv[])
>>>> {
>>>>  /*Create an instance of Csound*/
>>>>  Csound* csound = new Csound ;
>>>>  char csd[] = "example1.csd";
>>>>  csound->Compile(csd);
>>>>  char* msg;
>>>>  char channel[] = "string";
>>>>  csound->PerformKsmps();
>>>>  csound->GetStringChannel("string", msg);
>>>>  csound->Perform();
>>>>  /*delete instance of csound*/
>>>>  delete csound;
>>>> }
>>>>
>>>> I am running a performKsmps first to make sure the channel exists.
>>>> (btw, when does the first init-pass take place, is it during compile?)
>>>>
>>>> My Csound instrument looks like this:
>>>>
>>>> chn_S "string", 3
>>>> instr 1
>>>> chnset "test", "string"
>>>> endin
>>>>
>>>> When I run similar code from Cabbage I get the following problem:
>>>>
>>>> 0  0x00007ffff6ef6a50  pthread_spin_lock
>>>> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
>>>> 1  0x00007ffff6974d3e  csoundGetStringChannel
>>>> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
>>>> 2  0x00000000004e1ec9  Csound::GetStringChannel
>>>> /usr/local/include/csound/csound.hpp  760
>>>>
>>>> In Cabbage I only call that function as the end of a k cycle.
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Managing the Performance of Cloud-Based Applications
>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>> Read the Whitepaper.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Managing the Performance of Cloud-Based Applications
>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>> Read the Whitepaper.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-08 19:58
FromVictor Lazzarini
SubjectRe: [Cs-dev] more string questions..
Your program does not segfault here if there is enough memory available.

On 8 Feb 2014, at 18:42, Rory Walsh  wrote:

> Ok, it seems that I only get the segfault if I try to call
> GetStringChannel() before a call to performKsmps. When is the first
> init-pass done? The problem I have in Cabbage persists. It takes me to
> the following function and seg faults at the call to csoundSpinLock()?
> I'm on Linux btw.
> 
> void csoundGetStringChannel(CSOUND *csound, const char *name, char *string)
> {
>    MYFLT  *pstring;
>    if (csoundGetChannelPtr(csound, &pstring, name,
>                           CSOUND_STRING_CHANNEL | CSOUND_OUTPUT_CHANNEL)
>            == CSOUND_SUCCESS){
>      int *lock = csoundGetChannelLock(csound, (char*) name);
>      csoundSpinLock(lock);
>      strcpy(string, ((STRINGDAT *) pstring)->data);
>      csoundSpinUnLock(lock);
>    }
> }
> 
> On 8 February 2014 17:51, Victor Lazzarini  wrote:
>> and the code?
>> On 8 Feb 2014, at 17:25, Rory Walsh  wrote:
>> 
>>> Makes sense, but I still get a segfault char msg[256]?
>>> 
>>> #0  __strcpy_sse2_unaligned ()
>>>   at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:297
>>> #1  0x00007ffff7a6cd56 in csoundGetStringChannel (csound=0x609030,
>>>   name=0x40574b "string", string=0x7fffffffdf10 "")
>>>   at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:174
>>> #2  0x00000000004052a1 in Csound::GetStringChannel (this=0x609010,
>>>   name=0x40574b "string", string=0x7fffffffdf10 "")
>>>   at /usr/local/include/csound/csound.hpp:760
>>> #3  0x00000000004037c2 in main (argc=1, argv=0x7fffffffe118) at test.cpp:17
>>> 
>>> On 8 February 2014 17:13, Victor Lazzarini  wrote:
>>>> msg does not have any memory, I guess that's why it segfaults. Try using
>>>> msg[256] or allocating it dynamically.
>>>> 
>>>> On 8 Feb 2014, at 16:44, Rory Walsh  wrote:
>>>> 
>>>>> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
>>>>> 
>>>>> int main(int argc, char *argv[])
>>>>> {
>>>>> /*Create an instance of Csound*/
>>>>> Csound* csound = new Csound ;
>>>>> char csd[] = "example1.csd";
>>>>> csound->Compile(csd);
>>>>> char* msg;
>>>>> char channel[] = "string";
>>>>> csound->PerformKsmps();
>>>>> csound->GetStringChannel("string", msg);
>>>>> csound->Perform();
>>>>> /*delete instance of csound*/
>>>>> delete csound;
>>>>> }
>>>>> 
>>>>> I am running a performKsmps first to make sure the channel exists.
>>>>> (btw, when does the first init-pass take place, is it during compile?)
>>>>> 
>>>>> My Csound instrument looks like this:
>>>>> 
>>>>> chn_S "string", 3
>>>>> instr 1
>>>>> chnset "test", "string"
>>>>> endin
>>>>> 
>>>>> When I run similar code from Cabbage I get the following problem:
>>>>> 
>>>>> 0  0x00007ffff6ef6a50  pthread_spin_lock
>>>>> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
>>>>> 1  0x00007ffff6974d3e  csoundGetStringChannel
>>>>> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
>>>>> 2  0x00000000004e1ec9  Csound::GetStringChannel
>>>>> /usr/local/include/csound/csound.hpp  760
>>>>> 
>>>>> In Cabbage I only call that function as the end of a k cycle.
>>>>> 
>>>>> ------------------------------------------------------------------------------
>>>>> Managing the Performance of Cloud-Based Applications
>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>> Read the Whitepaper.
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>> 
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Managing the Performance of Cloud-Based Applications
>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>> Read the Whitepaper.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>> 
>>> ------------------------------------------------------------------------------
>>> Managing the Performance of Cloud-Based Applications
>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>> Read the Whitepaper.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> 
>> 
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-08 20:09
FromVictor Lazzarini
SubjectRe: [Cs-dev] more string questions..
I fixed it so that it will not crash. But trying to get a string channel before running performKsmps() does not make any sense.
There’s nothing to get.

Victor
On 8 Feb 2014, at 18:42, Rory Walsh  wrote:

> Ok, it seems that I only get the segfault if I try to call
> GetStringChannel() before a call to performKsmps. When is the first
> init-pass done? The problem I have in Cabbage persists. It takes me to
> the following function and seg faults at the call to csoundSpinLock()?
> I'm on Linux btw.
> 
> void csoundGetStringChannel(CSOUND *csound, const char *name, char *string)
> {
>    MYFLT  *pstring;
>    if (csoundGetChannelPtr(csound, &pstring, name,
>                           CSOUND_STRING_CHANNEL | CSOUND_OUTPUT_CHANNEL)
>            == CSOUND_SUCCESS){
>      int *lock = csoundGetChannelLock(csound, (char*) name);
>      csoundSpinLock(lock);
>      strcpy(string, ((STRINGDAT *) pstring)->data);
>      csoundSpinUnLock(lock);
>    }
> }
> 
> On 8 February 2014 17:51, Victor Lazzarini  wrote:
>> and the code?
>> On 8 Feb 2014, at 17:25, Rory Walsh  wrote:
>> 
>>> Makes sense, but I still get a segfault char msg[256]?
>>> 
>>> #0  __strcpy_sse2_unaligned ()
>>>   at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:297
>>> #1  0x00007ffff7a6cd56 in csoundGetStringChannel (csound=0x609030,
>>>   name=0x40574b "string", string=0x7fffffffdf10 "")
>>>   at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:174
>>> #2  0x00000000004052a1 in Csound::GetStringChannel (this=0x609010,
>>>   name=0x40574b "string", string=0x7fffffffdf10 "")
>>>   at /usr/local/include/csound/csound.hpp:760
>>> #3  0x00000000004037c2 in main (argc=1, argv=0x7fffffffe118) at test.cpp:17
>>> 
>>> On 8 February 2014 17:13, Victor Lazzarini  wrote:
>>>> msg does not have any memory, I guess that's why it segfaults. Try using
>>>> msg[256] or allocating it dynamically.
>>>> 
>>>> On 8 Feb 2014, at 16:44, Rory Walsh  wrote:
>>>> 
>>>>> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
>>>>> 
>>>>> int main(int argc, char *argv[])
>>>>> {
>>>>> /*Create an instance of Csound*/
>>>>> Csound* csound = new Csound ;
>>>>> char csd[] = "example1.csd";
>>>>> csound->Compile(csd);
>>>>> char* msg;
>>>>> char channel[] = "string";
>>>>> csound->PerformKsmps();
>>>>> csound->GetStringChannel("string", msg);
>>>>> csound->Perform();
>>>>> /*delete instance of csound*/
>>>>> delete csound;
>>>>> }
>>>>> 
>>>>> I am running a performKsmps first to make sure the channel exists.
>>>>> (btw, when does the first init-pass take place, is it during compile?)
>>>>> 
>>>>> My Csound instrument looks like this:
>>>>> 
>>>>> chn_S "string", 3
>>>>> instr 1
>>>>> chnset "test", "string"
>>>>> endin
>>>>> 
>>>>> When I run similar code from Cabbage I get the following problem:
>>>>> 
>>>>> 0  0x00007ffff6ef6a50  pthread_spin_lock
>>>>> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
>>>>> 1  0x00007ffff6974d3e  csoundGetStringChannel
>>>>> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
>>>>> 2  0x00000000004e1ec9  Csound::GetStringChannel
>>>>> /usr/local/include/csound/csound.hpp  760
>>>>> 
>>>>> In Cabbage I only call that function as the end of a k cycle.
>>>>> 
>>>>> ------------------------------------------------------------------------------
>>>>> Managing the Performance of Cloud-Based Applications
>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>> Read the Whitepaper.
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>> 
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Managing the Performance of Cloud-Based Applications
>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>> Read the Whitepaper.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>> 
>>> ------------------------------------------------------------------------------
>>> Managing the Performance of Cloud-Based Applications
>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>> Read the Whitepaper.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> 
>> 
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-08 20:11
FromRory Walsh
SubjectRe: [Cs-dev] more string questions..
Ok thanks Victor. Finally, does the init-pass take place on compile?

On 8 February 2014 19:58, Victor Lazzarini  wrote:
> Your program does not segfault here if there is enough memory available.
>
> On 8 Feb 2014, at 18:42, Rory Walsh  wrote:
>
>> Ok, it seems that I only get the segfault if I try to call
>> GetStringChannel() before a call to performKsmps. When is the first
>> init-pass done? The problem I have in Cabbage persists. It takes me to
>> the following function and seg faults at the call to csoundSpinLock()?
>> I'm on Linux btw.
>>
>> void csoundGetStringChannel(CSOUND *csound, const char *name, char *string)
>> {
>>    MYFLT  *pstring;
>>    if (csoundGetChannelPtr(csound, &pstring, name,
>>                           CSOUND_STRING_CHANNEL | CSOUND_OUTPUT_CHANNEL)
>>            == CSOUND_SUCCESS){
>>      int *lock = csoundGetChannelLock(csound, (char*) name);
>>      csoundSpinLock(lock);
>>      strcpy(string, ((STRINGDAT *) pstring)->data);
>>      csoundSpinUnLock(lock);
>>    }
>> }
>>
>> On 8 February 2014 17:51, Victor Lazzarini  wrote:
>>> and the code?
>>> On 8 Feb 2014, at 17:25, Rory Walsh  wrote:
>>>
>>>> Makes sense, but I still get a segfault char msg[256]?
>>>>
>>>> #0  __strcpy_sse2_unaligned ()
>>>>   at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:297
>>>> #1  0x00007ffff7a6cd56 in csoundGetStringChannel (csound=0x609030,
>>>>   name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>   at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:174
>>>> #2  0x00000000004052a1 in Csound::GetStringChannel (this=0x609010,
>>>>   name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>   at /usr/local/include/csound/csound.hpp:760
>>>> #3  0x00000000004037c2 in main (argc=1, argv=0x7fffffffe118) at test.cpp:17
>>>>
>>>> On 8 February 2014 17:13, Victor Lazzarini  wrote:
>>>>> msg does not have any memory, I guess that's why it segfaults. Try using
>>>>> msg[256] or allocating it dynamically.
>>>>>
>>>>> On 8 Feb 2014, at 16:44, Rory Walsh  wrote:
>>>>>
>>>>>> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
>>>>>>
>>>>>> int main(int argc, char *argv[])
>>>>>> {
>>>>>> /*Create an instance of Csound*/
>>>>>> Csound* csound = new Csound ;
>>>>>> char csd[] = "example1.csd";
>>>>>> csound->Compile(csd);
>>>>>> char* msg;
>>>>>> char channel[] = "string";
>>>>>> csound->PerformKsmps();
>>>>>> csound->GetStringChannel("string", msg);
>>>>>> csound->Perform();
>>>>>> /*delete instance of csound*/
>>>>>> delete csound;
>>>>>> }
>>>>>>
>>>>>> I am running a performKsmps first to make sure the channel exists.
>>>>>> (btw, when does the first init-pass take place, is it during compile?)
>>>>>>
>>>>>> My Csound instrument looks like this:
>>>>>>
>>>>>> chn_S "string", 3
>>>>>> instr 1
>>>>>> chnset "test", "string"
>>>>>> endin
>>>>>>
>>>>>> When I run similar code from Cabbage I get the following problem:
>>>>>>
>>>>>> 0  0x00007ffff6ef6a50  pthread_spin_lock
>>>>>> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
>>>>>> 1  0x00007ffff6974d3e  csoundGetStringChannel
>>>>>> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
>>>>>> 2  0x00000000004e1ec9  Csound::GetStringChannel
>>>>>> /usr/local/include/csound/csound.hpp  760
>>>>>>
>>>>>> In Cabbage I only call that function as the end of a k cycle.
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>> Read the Whitepaper.
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Managing the Performance of Cloud-Based Applications
>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>> Read the Whitepaper.
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Managing the Performance of Cloud-Based Applications
>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>> Read the Whitepaper.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Managing the Performance of Cloud-Based Applications
>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>> Read the Whitepaper.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-08 20:19
FromVictor Lazzarini
SubjectRe: [Cs-dev] more string questions..
It does.

Victor
On 8 Feb 2014, at 20:11, Rory Walsh  wrote:

> Ok thanks Victor. Finally, does the init-pass take place on compile?
> 
> On 8 February 2014 19:58, Victor Lazzarini  wrote:
>> Your program does not segfault here if there is enough memory available.
>> 
>> On 8 Feb 2014, at 18:42, Rory Walsh  wrote:
>> 
>>> Ok, it seems that I only get the segfault if I try to call
>>> GetStringChannel() before a call to performKsmps. When is the first
>>> init-pass done? The problem I have in Cabbage persists. It takes me to
>>> the following function and seg faults at the call to csoundSpinLock()?
>>> I'm on Linux btw.
>>> 
>>> void csoundGetStringChannel(CSOUND *csound, const char *name, char *string)
>>> {
>>>   MYFLT  *pstring;
>>>   if (csoundGetChannelPtr(csound, &pstring, name,
>>>                          CSOUND_STRING_CHANNEL | CSOUND_OUTPUT_CHANNEL)
>>>           == CSOUND_SUCCESS){
>>>     int *lock = csoundGetChannelLock(csound, (char*) name);
>>>     csoundSpinLock(lock);
>>>     strcpy(string, ((STRINGDAT *) pstring)->data);
>>>     csoundSpinUnLock(lock);
>>>   }
>>> }
>>> 
>>> On 8 February 2014 17:51, Victor Lazzarini  wrote:
>>>> and the code?
>>>> On 8 Feb 2014, at 17:25, Rory Walsh  wrote:
>>>> 
>>>>> Makes sense, but I still get a segfault char msg[256]?
>>>>> 
>>>>> #0  __strcpy_sse2_unaligned ()
>>>>>  at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:297
>>>>> #1  0x00007ffff7a6cd56 in csoundGetStringChannel (csound=0x609030,
>>>>>  name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>>  at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:174
>>>>> #2  0x00000000004052a1 in Csound::GetStringChannel (this=0x609010,
>>>>>  name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>>  at /usr/local/include/csound/csound.hpp:760
>>>>> #3  0x00000000004037c2 in main (argc=1, argv=0x7fffffffe118) at test.cpp:17
>>>>> 
>>>>> On 8 February 2014 17:13, Victor Lazzarini  wrote:
>>>>>> msg does not have any memory, I guess that's why it segfaults. Try using
>>>>>> msg[256] or allocating it dynamically.
>>>>>> 
>>>>>> On 8 Feb 2014, at 16:44, Rory Walsh  wrote:
>>>>>> 
>>>>>>> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
>>>>>>> 
>>>>>>> int main(int argc, char *argv[])
>>>>>>> {
>>>>>>> /*Create an instance of Csound*/
>>>>>>> Csound* csound = new Csound ;
>>>>>>> char csd[] = "example1.csd";
>>>>>>> csound->Compile(csd);
>>>>>>> char* msg;
>>>>>>> char channel[] = "string";
>>>>>>> csound->PerformKsmps();
>>>>>>> csound->GetStringChannel("string", msg);
>>>>>>> csound->Perform();
>>>>>>> /*delete instance of csound*/
>>>>>>> delete csound;
>>>>>>> }
>>>>>>> 
>>>>>>> I am running a performKsmps first to make sure the channel exists.
>>>>>>> (btw, when does the first init-pass take place, is it during compile?)
>>>>>>> 
>>>>>>> My Csound instrument looks like this:
>>>>>>> 
>>>>>>> chn_S "string", 3
>>>>>>> instr 1
>>>>>>> chnset "test", "string"
>>>>>>> endin
>>>>>>> 
>>>>>>> When I run similar code from Cabbage I get the following problem:
>>>>>>> 
>>>>>>> 0  0x00007ffff6ef6a50  pthread_spin_lock
>>>>>>> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
>>>>>>> 1  0x00007ffff6974d3e  csoundGetStringChannel
>>>>>>> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
>>>>>>> 2  0x00000000004e1ec9  Csound::GetStringChannel
>>>>>>> /usr/local/include/csound/csound.hpp  760
>>>>>>> 
>>>>>>> In Cabbage I only call that function as the end of a k cycle.
>>>>>>> 
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>> Read the Whitepaper.
>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>> 
>>>>>> 
>>>>>> ------------------------------------------------------------------------------
>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>> Read the Whitepaper.
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>> 
>>>>> ------------------------------------------------------------------------------
>>>>> Managing the Performance of Cloud-Based Applications
>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>> Read the Whitepaper.
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>> 
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Managing the Performance of Cloud-Based Applications
>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>> Read the Whitepaper.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>> 
>>> ------------------------------------------------------------------------------
>>> Managing the Performance of Cloud-Based Applications
>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>> Read the Whitepaper.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> 
>> 
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-08 20:29
FromRory Walsh
SubjectRe: [Cs-dev] more string questions..
Cheers, I'm shutting down shop for the night. I'll let you tomorrow if
I have any further difficulties. I'm only experimenting with this
stuff for now.

On 8 February 2014 20:31, Victor Lazzarini  wrote:
> I think the locks were Ok, but I put check on them anyway. Major issue was that the channel did not contain a string and then it segfaulted.
> I protected that now.
>
> On 8 Feb 2014, at 20:19, Victor Lazzarini  wrote:
>
>> It does.
>>
>> Victor
>> On 8 Feb 2014, at 20:11, Rory Walsh  wrote:
>>
>>> Ok thanks Victor. Finally, does the init-pass take place on compile?
>>>
>>> On 8 February 2014 19:58, Victor Lazzarini  wrote:
>>>> Your program does not segfault here if there is enough memory available.
>>>>
>>>> On 8 Feb 2014, at 18:42, Rory Walsh  wrote:
>>>>
>>>>> Ok, it seems that I only get the segfault if I try to call
>>>>> GetStringChannel() before a call to performKsmps. When is the first
>>>>> init-pass done? The problem I have in Cabbage persists. It takes me to
>>>>> the following function and seg faults at the call to csoundSpinLock()?
>>>>> I'm on Linux btw.
>>>>>
>>>>> void csoundGetStringChannel(CSOUND *csound, const char *name, char *string)
>>>>> {
>>>>>  MYFLT  *pstring;
>>>>>  if (csoundGetChannelPtr(csound, &pstring, name,
>>>>>                         CSOUND_STRING_CHANNEL | CSOUND_OUTPUT_CHANNEL)
>>>>>          == CSOUND_SUCCESS){
>>>>>    int *lock = csoundGetChannelLock(csound, (char*) name);
>>>>>    csoundSpinLock(lock);
>>>>>    strcpy(string, ((STRINGDAT *) pstring)->data);
>>>>>    csoundSpinUnLock(lock);
>>>>>  }
>>>>> }
>>>>>
>>>>> On 8 February 2014 17:51, Victor Lazzarini  wrote:
>>>>>> and the code?
>>>>>> On 8 Feb 2014, at 17:25, Rory Walsh  wrote:
>>>>>>
>>>>>>> Makes sense, but I still get a segfault char msg[256]?
>>>>>>>
>>>>>>> #0  __strcpy_sse2_unaligned ()
>>>>>>> at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:297
>>>>>>> #1  0x00007ffff7a6cd56 in csoundGetStringChannel (csound=0x609030,
>>>>>>> name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>>>> at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:174
>>>>>>> #2  0x00000000004052a1 in Csound::GetStringChannel (this=0x609010,
>>>>>>> name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>>>> at /usr/local/include/csound/csound.hpp:760
>>>>>>> #3  0x00000000004037c2 in main (argc=1, argv=0x7fffffffe118) at test.cpp:17
>>>>>>>
>>>>>>> On 8 February 2014 17:13, Victor Lazzarini  wrote:
>>>>>>>> msg does not have any memory, I guess that's why it segfaults. Try using
>>>>>>>> msg[256] or allocating it dynamically.
>>>>>>>>
>>>>>>>> On 8 Feb 2014, at 16:44, Rory Walsh  wrote:
>>>>>>>>
>>>>>>>>> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
>>>>>>>>>
>>>>>>>>> int main(int argc, char *argv[])
>>>>>>>>> {
>>>>>>>>> /*Create an instance of Csound*/
>>>>>>>>> Csound* csound = new Csound ;
>>>>>>>>> char csd[] = "example1.csd";
>>>>>>>>> csound->Compile(csd);
>>>>>>>>> char* msg;
>>>>>>>>> char channel[] = "string";
>>>>>>>>> csound->PerformKsmps();
>>>>>>>>> csound->GetStringChannel("string", msg);
>>>>>>>>> csound->Perform();
>>>>>>>>> /*delete instance of csound*/
>>>>>>>>> delete csound;
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> I am running a performKsmps first to make sure the channel exists.
>>>>>>>>> (btw, when does the first init-pass take place, is it during compile?)
>>>>>>>>>
>>>>>>>>> My Csound instrument looks like this:
>>>>>>>>>
>>>>>>>>> chn_S "string", 3
>>>>>>>>> instr 1
>>>>>>>>> chnset "test", "string"
>>>>>>>>> endin
>>>>>>>>>
>>>>>>>>> When I run similar code from Cabbage I get the following problem:
>>>>>>>>>
>>>>>>>>> 0  0x00007ffff6ef6a50  pthread_spin_lock
>>>>>>>>> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
>>>>>>>>> 1  0x00007ffff6974d3e  csoundGetStringChannel
>>>>>>>>> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
>>>>>>>>> 2  0x00000000004e1ec9  Csound::GetStringChannel
>>>>>>>>> /usr/local/include/csound/csound.hpp  760
>>>>>>>>>
>>>>>>>>> In Cabbage I only call that function as the end of a k cycle.
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>>>> Read the Whitepaper.
>>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>>>> _______________________________________________
>>>>>>>>> Csound-devel mailing list
>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>>> Read the Whitepaper.
>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>> Read the Whitepaper.
>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>> Read the Whitepaper.
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Managing the Performance of Cloud-Based Applications
>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>> Read the Whitepaper.
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Managing the Performance of Cloud-Based Applications
>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>> Read the Whitepaper.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>> ------------------------------------------------------------------------------
>>> Managing the Performance of Cloud-Based Applications
>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>> Read the Whitepaper.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-08 20:31
FromVictor Lazzarini
SubjectRe: [Cs-dev] more string questions..
I think the locks were Ok, but I put check on them anyway. Major issue was that the channel did not contain a string and then it segfaulted.
I protected that now.

On 8 Feb 2014, at 20:19, Victor Lazzarini  wrote:

> It does.
> 
> Victor
> On 8 Feb 2014, at 20:11, Rory Walsh  wrote:
> 
>> Ok thanks Victor. Finally, does the init-pass take place on compile?
>> 
>> On 8 February 2014 19:58, Victor Lazzarini  wrote:
>>> Your program does not segfault here if there is enough memory available.
>>> 
>>> On 8 Feb 2014, at 18:42, Rory Walsh  wrote:
>>> 
>>>> Ok, it seems that I only get the segfault if I try to call
>>>> GetStringChannel() before a call to performKsmps. When is the first
>>>> init-pass done? The problem I have in Cabbage persists. It takes me to
>>>> the following function and seg faults at the call to csoundSpinLock()?
>>>> I'm on Linux btw.
>>>> 
>>>> void csoundGetStringChannel(CSOUND *csound, const char *name, char *string)
>>>> {
>>>>  MYFLT  *pstring;
>>>>  if (csoundGetChannelPtr(csound, &pstring, name,
>>>>                         CSOUND_STRING_CHANNEL | CSOUND_OUTPUT_CHANNEL)
>>>>          == CSOUND_SUCCESS){
>>>>    int *lock = csoundGetChannelLock(csound, (char*) name);
>>>>    csoundSpinLock(lock);
>>>>    strcpy(string, ((STRINGDAT *) pstring)->data);
>>>>    csoundSpinUnLock(lock);
>>>>  }
>>>> }
>>>> 
>>>> On 8 February 2014 17:51, Victor Lazzarini  wrote:
>>>>> and the code?
>>>>> On 8 Feb 2014, at 17:25, Rory Walsh  wrote:
>>>>> 
>>>>>> Makes sense, but I still get a segfault char msg[256]?
>>>>>> 
>>>>>> #0  __strcpy_sse2_unaligned ()
>>>>>> at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:297
>>>>>> #1  0x00007ffff7a6cd56 in csoundGetStringChannel (csound=0x609030,
>>>>>> name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>>> at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:174
>>>>>> #2  0x00000000004052a1 in Csound::GetStringChannel (this=0x609010,
>>>>>> name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>>> at /usr/local/include/csound/csound.hpp:760
>>>>>> #3  0x00000000004037c2 in main (argc=1, argv=0x7fffffffe118) at test.cpp:17
>>>>>> 
>>>>>> On 8 February 2014 17:13, Victor Lazzarini  wrote:
>>>>>>> msg does not have any memory, I guess that's why it segfaults. Try using
>>>>>>> msg[256] or allocating it dynamically.
>>>>>>> 
>>>>>>> On 8 Feb 2014, at 16:44, Rory Walsh  wrote:
>>>>>>> 
>>>>>>>> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
>>>>>>>> 
>>>>>>>> int main(int argc, char *argv[])
>>>>>>>> {
>>>>>>>> /*Create an instance of Csound*/
>>>>>>>> Csound* csound = new Csound ;
>>>>>>>> char csd[] = "example1.csd";
>>>>>>>> csound->Compile(csd);
>>>>>>>> char* msg;
>>>>>>>> char channel[] = "string";
>>>>>>>> csound->PerformKsmps();
>>>>>>>> csound->GetStringChannel("string", msg);
>>>>>>>> csound->Perform();
>>>>>>>> /*delete instance of csound*/
>>>>>>>> delete csound;
>>>>>>>> }
>>>>>>>> 
>>>>>>>> I am running a performKsmps first to make sure the channel exists.
>>>>>>>> (btw, when does the first init-pass take place, is it during compile?)
>>>>>>>> 
>>>>>>>> My Csound instrument looks like this:
>>>>>>>> 
>>>>>>>> chn_S "string", 3
>>>>>>>> instr 1
>>>>>>>> chnset "test", "string"
>>>>>>>> endin
>>>>>>>> 
>>>>>>>> When I run similar code from Cabbage I get the following problem:
>>>>>>>> 
>>>>>>>> 0  0x00007ffff6ef6a50  pthread_spin_lock
>>>>>>>> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
>>>>>>>> 1  0x00007ffff6974d3e  csoundGetStringChannel
>>>>>>>> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
>>>>>>>> 2  0x00000000004e1ec9  Csound::GetStringChannel
>>>>>>>> /usr/local/include/csound/csound.hpp  760
>>>>>>>> 
>>>>>>>> In Cabbage I only call that function as the end of a k cycle.
>>>>>>>> 
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>>> Read the Whitepaper.
>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>> 
>>>>>>> 
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>> Read the Whitepaper.
>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>> 
>>>>>> ------------------------------------------------------------------------------
>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>> Read the Whitepaper.
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>> 
>>>>> 
>>>>> ------------------------------------------------------------------------------
>>>>> Managing the Performance of Cloud-Based Applications
>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>> Read the Whitepaper.
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Managing the Performance of Cloud-Based Applications
>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>> Read the Whitepaper.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> Managing the Performance of Cloud-Based Applications
>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>> Read the Whitepaper.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>> 
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-09 17:53
FromRory Walsh
SubjectRe: [Cs-dev] more string questions..
I just tried your latest changes Victor and GetStringChannel() no
longer seems to work. The simple test below no longer prints the
channel message. I sorted out the crash I was having in Cabbage by
being more careful with my string channels so I can work with an
earlier tip. Maybe I'm still missing something?

int main(int argc, char *argv[])
{
/*Create an instance of Csound*/
Csound* csound = new Csound;
char csd[] = "example1.csd";
csound->Compile(csd);
char msg[256];
char channel[] = "string";
csound->PerformKsmps();
csound->GetStringChannel("string", msg);
csound->Message("string message = %s", msg);
csound->Perform();
/*delete instance of csound*/
delete csound;
}

/* ==== csound code =====
chn_S "string", 3
instr 1
chnset "test", "string"
endin
*/

On 8 February 2014 20:29, Rory Walsh  wrote:
> Cheers, I'm shutting down shop for the night. I'll let you tomorrow if
> I have any further difficulties. I'm only experimenting with this
> stuff for now.
>
> On 8 February 2014 20:31, Victor Lazzarini  wrote:
>> I think the locks were Ok, but I put check on them anyway. Major issue was that the channel did not contain a string and then it segfaulted.
>> I protected that now.
>>
>> On 8 Feb 2014, at 20:19, Victor Lazzarini  wrote:
>>
>>> It does.
>>>
>>> Victor
>>> On 8 Feb 2014, at 20:11, Rory Walsh  wrote:
>>>
>>>> Ok thanks Victor. Finally, does the init-pass take place on compile?
>>>>
>>>> On 8 February 2014 19:58, Victor Lazzarini  wrote:
>>>>> Your program does not segfault here if there is enough memory available.
>>>>>
>>>>> On 8 Feb 2014, at 18:42, Rory Walsh  wrote:
>>>>>
>>>>>> Ok, it seems that I only get the segfault if I try to call
>>>>>> GetStringChannel() before a call to performKsmps. When is the first
>>>>>> init-pass done? The problem I have in Cabbage persists. It takes me to
>>>>>> the following function and seg faults at the call to csoundSpinLock()?
>>>>>> I'm on Linux btw.
>>>>>>
>>>>>> void csoundGetStringChannel(CSOUND *csound, const char *name, char *string)
>>>>>> {
>>>>>>  MYFLT  *pstring;
>>>>>>  if (csoundGetChannelPtr(csound, &pstring, name,
>>>>>>                         CSOUND_STRING_CHANNEL | CSOUND_OUTPUT_CHANNEL)
>>>>>>          == CSOUND_SUCCESS){
>>>>>>    int *lock = csoundGetChannelLock(csound, (char*) name);
>>>>>>    csoundSpinLock(lock);
>>>>>>    strcpy(string, ((STRINGDAT *) pstring)->data);
>>>>>>    csoundSpinUnLock(lock);
>>>>>>  }
>>>>>> }
>>>>>>
>>>>>> On 8 February 2014 17:51, Victor Lazzarini  wrote:
>>>>>>> and the code?
>>>>>>> On 8 Feb 2014, at 17:25, Rory Walsh  wrote:
>>>>>>>
>>>>>>>> Makes sense, but I still get a segfault char msg[256]?
>>>>>>>>
>>>>>>>> #0  __strcpy_sse2_unaligned ()
>>>>>>>> at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:297
>>>>>>>> #1  0x00007ffff7a6cd56 in csoundGetStringChannel (csound=0x609030,
>>>>>>>> name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>>>>> at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:174
>>>>>>>> #2  0x00000000004052a1 in Csound::GetStringChannel (this=0x609010,
>>>>>>>> name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>>>>> at /usr/local/include/csound/csound.hpp:760
>>>>>>>> #3  0x00000000004037c2 in main (argc=1, argv=0x7fffffffe118) at test.cpp:17
>>>>>>>>
>>>>>>>> On 8 February 2014 17:13, Victor Lazzarini  wrote:
>>>>>>>>> msg does not have any memory, I guess that's why it segfaults. Try using
>>>>>>>>> msg[256] or allocating it dynamically.
>>>>>>>>>
>>>>>>>>> On 8 Feb 2014, at 16:44, Rory Walsh  wrote:
>>>>>>>>>
>>>>>>>>>> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
>>>>>>>>>>
>>>>>>>>>> int main(int argc, char *argv[])
>>>>>>>>>> {
>>>>>>>>>> /*Create an instance of Csound*/
>>>>>>>>>> Csound* csound = new Csound ;
>>>>>>>>>> char csd[] = "example1.csd";
>>>>>>>>>> csound->Compile(csd);
>>>>>>>>>> char* msg;
>>>>>>>>>> char channel[] = "string";
>>>>>>>>>> csound->PerformKsmps();
>>>>>>>>>> csound->GetStringChannel("string", msg);
>>>>>>>>>> csound->Perform();
>>>>>>>>>> /*delete instance of csound*/
>>>>>>>>>> delete csound;
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> I am running a performKsmps first to make sure the channel exists.
>>>>>>>>>> (btw, when does the first init-pass take place, is it during compile?)
>>>>>>>>>>
>>>>>>>>>> My Csound instrument looks like this:
>>>>>>>>>>
>>>>>>>>>> chn_S "string", 3
>>>>>>>>>> instr 1
>>>>>>>>>> chnset "test", "string"
>>>>>>>>>> endin
>>>>>>>>>>
>>>>>>>>>> When I run similar code from Cabbage I get the following problem:
>>>>>>>>>>
>>>>>>>>>> 0  0x00007ffff6ef6a50  pthread_spin_lock
>>>>>>>>>> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
>>>>>>>>>> 1  0x00007ffff6974d3e  csoundGetStringChannel
>>>>>>>>>> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
>>>>>>>>>> 2  0x00000000004e1ec9  Csound::GetStringChannel
>>>>>>>>>> /usr/local/include/csound/csound.hpp  760
>>>>>>>>>>
>>>>>>>>>> In Cabbage I only call that function as the end of a k cycle.
>>>>>>>>>>
>>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>>>>> Read the Whitepaper.
>>>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Csound-devel mailing list
>>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>>>> Read the Whitepaper.
>>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>>>> _______________________________________________
>>>>>>>>> Csound-devel mailing list
>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>>> Read the Whitepaper.
>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>> Read the Whitepaper.
>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>> Read the Whitepaper.
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Managing the Performance of Cloud-Based Applications
>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>> Read the Whitepaper.
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Managing the Performance of Cloud-Based Applications
>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>> Read the Whitepaper.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Managing the Performance of Cloud-Based Applications
>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>> Read the Whitepaper.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-02-09 19:08
FromVictor Lazzarini
SubjectRe: [Cs-dev] more string questions..
yes, because I was being ultrasafe and testing the size of the string you tried to copy into,
but that will be 0. I changed it, but remember you will need enough memory for your string,
otherwise it’ll crash. In GIT now, working.

Victor

On 9 Feb 2014, at 17:53, Rory Walsh  wrote:

> I just tried your latest changes Victor and GetStringChannel() no
> longer seems to work. The simple test below no longer prints the
> channel message. I sorted out the crash I was having in Cabbage by
> being more careful with my string channels so I can work with an
> earlier tip. Maybe I'm still missing something?
> 
> int main(int argc, char *argv[])
> {
> /*Create an instance of Csound*/
> Csound* csound = new Csound;
> char csd[] = "example1.csd";
> csound->Compile(csd);
> char msg[256];
> char channel[] = "string";
> csound->PerformKsmps();
> csound->GetStringChannel("string", msg);
> csound->Message("string message = %s", msg);
> csound->Perform();
> /*delete instance of csound*/
> delete csound;
> }
> 
> /* ==== csound code =====
> chn_S "string", 3
> instr 1
> chnset "test", "string"
> endin
> */
> 
> On 8 February 2014 20:29, Rory Walsh  wrote:
>> Cheers, I'm shutting down shop for the night. I'll let you tomorrow if
>> I have any further difficulties. I'm only experimenting with this
>> stuff for now.
>> 
>> On 8 February 2014 20:31, Victor Lazzarini  wrote:
>>> I think the locks were Ok, but I put check on them anyway. Major issue was that the channel did not contain a string and then it segfaulted.
>>> I protected that now.
>>> 
>>> On 8 Feb 2014, at 20:19, Victor Lazzarini  wrote:
>>> 
>>>> It does.
>>>> 
>>>> Victor
>>>> On 8 Feb 2014, at 20:11, Rory Walsh  wrote:
>>>> 
>>>>> Ok thanks Victor. Finally, does the init-pass take place on compile?
>>>>> 
>>>>> On 8 February 2014 19:58, Victor Lazzarini  wrote:
>>>>>> Your program does not segfault here if there is enough memory available.
>>>>>> 
>>>>>> On 8 Feb 2014, at 18:42, Rory Walsh  wrote:
>>>>>> 
>>>>>>> Ok, it seems that I only get the segfault if I try to call
>>>>>>> GetStringChannel() before a call to performKsmps. When is the first
>>>>>>> init-pass done? The problem I have in Cabbage persists. It takes me to
>>>>>>> the following function and seg faults at the call to csoundSpinLock()?
>>>>>>> I'm on Linux btw.
>>>>>>> 
>>>>>>> void csoundGetStringChannel(CSOUND *csound, const char *name, char *string)
>>>>>>> {
>>>>>>> MYFLT  *pstring;
>>>>>>> if (csoundGetChannelPtr(csound, &pstring, name,
>>>>>>>                        CSOUND_STRING_CHANNEL | CSOUND_OUTPUT_CHANNEL)
>>>>>>>         == CSOUND_SUCCESS){
>>>>>>>   int *lock = csoundGetChannelLock(csound, (char*) name);
>>>>>>>   csoundSpinLock(lock);
>>>>>>>   strcpy(string, ((STRINGDAT *) pstring)->data);
>>>>>>>   csoundSpinUnLock(lock);
>>>>>>> }
>>>>>>> }
>>>>>>> 
>>>>>>> On 8 February 2014 17:51, Victor Lazzarini  wrote:
>>>>>>>> and the code?
>>>>>>>> On 8 Feb 2014, at 17:25, Rory Walsh  wrote:
>>>>>>>> 
>>>>>>>>> Makes sense, but I still get a segfault char msg[256]?
>>>>>>>>> 
>>>>>>>>> #0  __strcpy_sse2_unaligned ()
>>>>>>>>> at ../sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S:297
>>>>>>>>> #1  0x00007ffff7a6cd56 in csoundGetStringChannel (csound=0x609030,
>>>>>>>>> name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>>>>>> at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:174
>>>>>>>>> #2  0x00000000004052a1 in Csound::GetStringChannel (this=0x609010,
>>>>>>>>> name=0x40574b "string", string=0x7fffffffdf10 "")
>>>>>>>>> at /usr/local/include/csound/csound.hpp:760
>>>>>>>>> #3  0x00000000004037c2 in main (argc=1, argv=0x7fffffffe118) at test.cpp:17
>>>>>>>>> 
>>>>>>>>> On 8 February 2014 17:13, Victor Lazzarini  wrote:
>>>>>>>>>> msg does not have any memory, I guess that's why it segfaults. Try using
>>>>>>>>>> msg[256] or allocating it dynamically.
>>>>>>>>>> 
>>>>>>>>>> On 8 Feb 2014, at 16:44, Rory Walsh  wrote:
>>>>>>>>>> 
>>>>>>>>>>> The following segfaults Csound(GetStringChannel()). Am I doing something wrong?
>>>>>>>>>>> 
>>>>>>>>>>> int main(int argc, char *argv[])
>>>>>>>>>>> {
>>>>>>>>>>> /*Create an instance of Csound*/
>>>>>>>>>>> Csound* csound = new Csound ;
>>>>>>>>>>> char csd[] = "example1.csd";
>>>>>>>>>>> csound->Compile(csd);
>>>>>>>>>>> char* msg;
>>>>>>>>>>> char channel[] = "string";
>>>>>>>>>>> csound->PerformKsmps();
>>>>>>>>>>> csound->GetStringChannel("string", msg);
>>>>>>>>>>> csound->Perform();
>>>>>>>>>>> /*delete instance of csound*/
>>>>>>>>>>> delete csound;
>>>>>>>>>>> }
>>>>>>>>>>> 
>>>>>>>>>>> I am running a performKsmps first to make sure the channel exists.
>>>>>>>>>>> (btw, when does the first init-pass take place, is it during compile?)
>>>>>>>>>>> 
>>>>>>>>>>> My Csound instrument looks like this:
>>>>>>>>>>> 
>>>>>>>>>>> chn_S "string", 3
>>>>>>>>>>> instr 1
>>>>>>>>>>> chnset "test", "string"
>>>>>>>>>>> endin
>>>>>>>>>>> 
>>>>>>>>>>> When I run similar code from Cabbage I get the following problem:
>>>>>>>>>>> 
>>>>>>>>>>> 0  0x00007ffff6ef6a50  pthread_spin_lock
>>>>>>>>>>> ../nptl/sysdeps/x86_64/../i386/pthread_spin_lock.c  35
>>>>>>>>>>> 1  0x00007ffff6974d3e  csoundGetStringChannel
>>>>>>>>>>> /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c  173
>>>>>>>>>>> 2  0x00000000004e1ec9  Csound::GetStringChannel
>>>>>>>>>>> /usr/local/include/csound/csound.hpp  760
>>>>>>>>>>> 
>>>>>>>>>>> In Cabbage I only call that function as the end of a k cycle.
>>>>>>>>>>> 
>>>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>>>>>> Read the Whitepaper.
>>>>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> Csound-devel mailing list
>>>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>>>>> Read the Whitepaper.
>>>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Csound-devel mailing list
>>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>>> 
>>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>>>> Read the Whitepaper.
>>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>>>> _______________________________________________
>>>>>>>>> Csound-devel mailing list
>>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>>> 
>>>>>>>> 
>>>>>>>> ------------------------------------------------------------------------------
>>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>>> Read the Whitepaper.
>>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>>> _______________________________________________
>>>>>>>> Csound-devel mailing list
>>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>>> 
>>>>>>> ------------------------------------------------------------------------------
>>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>>> Read the Whitepaper.
>>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>>> _______________________________________________
>>>>>>> Csound-devel mailing list
>>>>>>> Csound-devel@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>>> 
>>>>>> 
>>>>>> ------------------------------------------------------------------------------
>>>>>> Managing the Performance of Cloud-Based Applications
>>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>>> Read the Whitepaper.
>>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>>> _______________________________________________
>>>>>> Csound-devel mailing list
>>>>>> Csound-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>>> 
>>>>> ------------------------------------------------------------------------------
>>>>> Managing the Performance of Cloud-Based Applications
>>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>>> Read the Whitepaper.
>>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>>> _______________________________________________
>>>>> Csound-devel mailing list
>>>>> Csound-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>>> 
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Managing the Performance of Cloud-Based Applications
>>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>>> Read the Whitepaper.
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Csound-devel mailing list
>>>> Csound-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> Managing the Performance of Cloud-Based Applications
>>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>>> Read the Whitepaper.
>>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Csound-devel mailing list
>>> Csound-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net