Csound Csound-dev Csound-tekno Search About

[Cs-dev] Csound API Segmentation Fault

Date2015-10-05 16:48
FromPeter Burgess
Subject[Cs-dev] Csound API Segmentation Fault
AttachmentsNone  None  
I keep getting a segmentation fault while compiling a .csd file that works 95% of the time. It is recompiled multiple times in my program, and just occasionally throws up a segmentation fault and quits. I can run the same .csd fine from terminal

While the overall c++ program is insanely complex, my implementation of csound is simple enough:

static Csound csound;

void exportWav (char* csdFileName) {

    csound.Compile(csdFileName);
    csound.Perform();
    csound.Reset();
}

A debug directs me to this section of the Csound API:

  virtual int Compile(char *csdName)
  {
    char  *argv[3];
    argv[0] = (char*)"csound";
    argv[1] = csdName;
    argv[2] = (char*) 0;
    return csoundCompile(csound, 2, &(argv[0]));     <--- Pointing specifically at this line
  }

This message also shows up in the terminal

sfinit: cannot open /wav/testscore.wav

I wondered if it was my implementation of Csound that was the problem, as I decided to try using it as a static variable that I just reset between uses, but I have tried using a Csound*, a static Csound* and just a Csound and all present the same issue.

So it is clear that something is causing it to trip over during compilation, but I'm not sure what

Cheers in advance for any advice you can offer

Date2015-10-05 16:56
FromVictor Lazzarini
SubjectRe: [Cs-dev] Csound API Segmentation Fault
You can try using this function instead:

Csound::Compile(int argv, char *argc)

regards

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

> On 5 Oct 2015, at 16:48, Peter Burgess  wrote:
> 
> I keep getting a segmentation fault while compiling a .csd file that works 95% of the time. It is recompiled multiple times in my program, and just occasionally throws up a segmentation fault and quits. I can run the same .csd fine from terminal
> 
> While the overall c++ program is insanely complex, my implementation of csound is simple enough:
> 
> static Csound csound;
> 
> void exportWav (char* csdFileName) {
> 
>     csound.Compile(csdFileName);
>     csound.Perform();
>     csound.Reset();
> }
> 
> A debug directs me to this section of the Csound API:
> 
>   virtual int Compile(char *csdName)
>   {
>     char  *argv[3];
>     argv[0] = (char*)"csound";
>     argv[1] = csdName;
>     argv[2] = (char*) 0;
>     return csoundCompile(csound, 2, &(argv[0]));     <--- Pointing specifically at this line
>   }
> 
> This message also shows up in the terminal
> 
> sfinit: cannot open /wav/testscore.wav
> 
> I wondered if it was my implementation of Csound that was the problem, as I decided to try using it as a static variable that I just reset between uses, but I have tried using a Csound*, a static Csound* and just a Csound and all present the same issue.
> 
> So it is clear that something is causing it to trip over during compilation, but I'm not sure what
> 
> Cheers in advance for any advice you can offer 
> ------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2015-10-05 17:12
FromPeter Burgess
SubjectRe: [Cs-dev] Csound API Segmentation Fault
AttachmentsNone  None  
I'm not sure this will work for me, as the csd filename can change, and is decided by the c++ program, so argv does not contain the desired infomation (although I've only recently come to understand the use of argc and argv, so I may have this all wrong!)

While on the subject, is there a way of stopping csound crashing the program if this happens, allowing the chance to try to compile it again? Something like this:

    int result = -1;
    while (result != 0) {
        result = csound.Compile(csdFileName);
    }

The above compiles and runs but doesn't actually save the program from crashing

Cheers for your help!

Pete

On Mon, Oct 5, 2015 at 4:56 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
You can try using this function instead:

Csound::Compile(int argv, char *argc)

regards

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

> On 5 Oct 2015, at 16:48, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
>
> I keep getting a segmentation fault while compiling a .csd file that works 95% of the time. It is recompiled multiple times in my program, and just occasionally throws up a segmentation fault and quits. I can run the same .csd fine from terminal
>
> While the overall c++ program is insanely complex, my implementation of csound is simple enough:
>
> static Csound csound;
>
> void exportWav (char* csdFileName) {
>
>     csound.Compile(csdFileName);
>     csound.Perform();
>     csound.Reset();
> }
>
> A debug directs me to this section of the Csound API:
>
>   virtual int Compile(char *csdName)
>   {
>     char  *argv[3];
>     argv[0] = (char*)"csound";
>     argv[1] = csdName;
>     argv[2] = (char*) 0;
>     return csoundCompile(csound, 2, &(argv[0]));     <--- Pointing specifically at this line
>   }
>
> This message also shows up in the terminal
>
> sfinit: cannot open /wav/testscore.wav
>
> I wondered if it was my implementation of Csound that was the problem, as I decided to try using it as a static variable that I just reset between uses, but I have tried using a Csound*, a static Csound* and just a Csound and all present the same issue.
>
> So it is clear that something is causing it to trip over during compilation, but I'm not sure what
>
> Cheers in advance for any advice you can offer
> ------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2015-10-05 17:18
FromMichael Gogins
SubjectRe: [Cs-dev] Csound API Segmentation Fault
AttachmentsNone  None  

Try copying the  strings with strdup not assigning them.

Regards,
Mike

On Oct 5, 2015 11:48 AM, "Peter Burgess" <pete.soundtechnician@gmail.com> wrote:
I keep getting a segmentation fault while compiling a .csd file that works 95% of the time. It is recompiled multiple times in my program, and just occasionally throws up a segmentation fault and quits. I can run the same .csd fine from terminal

While the overall c++ program is insanely complex, my implementation of csound is simple enough:

static Csound csound;

void exportWav (char* csdFileName) {

    csound.Compile(csdFileName);
    csound.Perform();
    csound.Reset();
}

A debug directs me to this section of the Csound API:

  virtual int Compile(char *csdName)
  {
    char  *argv[3];
    argv[0] = (char*)"csound";
    argv[1] = csdName;
    argv[2] = (char*) 0;
    return csoundCompile(csound, 2, &(argv[0]));     <--- Pointing specifically at this line
  }

This message also shows up in the terminal

sfinit: cannot open /wav/testscore.wav

I wondered if it was my implementation of Csound that was the problem, as I decided to try using it as a static variable that I just reset between uses, but I have tried using a Csound*, a static Csound* and just a Csound and all present the same issue.

So it is clear that something is causing it to trip over during compilation, but I'm not sure what

Cheers in advance for any advice you can offer

------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2015-10-05 17:20
FromVictor Lazzarini
SubjectRe: [Cs-dev] Csound API Segmentation Fault
AttachmentsNone  None  
You just have to pass the CSD as one of the arguments. Argv is just an array of strings,
which you can create yourself when you need it. You always need to check the return value of the compilation function, because if there was an error, you should not proceed.

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

On 5 Oct 2015, at 17:12, Peter Burgess <pete.soundtechnician@gmail.com> wrote:

I'm not sure this will work for me, as the csd filename can change, and is decided by the c++ program, so argv does not contain the desired infomation (although I've only recently come to understand the use of argc and argv, so I may have this all wrong!)

While on the subject, is there a way of stopping csound crashing the program if this happens, allowing the chance to try to compile it again? Something like this:

    int result = -1;
    while (result != 0) {
        result = csound.Compile(csdFileName);
    }

The above compiles and runs but doesn't actually save the program from crashing

Cheers for your help!

Pete

On Mon, Oct 5, 2015 at 4:56 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
You can try using this function instead:

Csound::Compile(int argv, char *argc)

regards

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

> On 5 Oct 2015, at 16:48, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
>
> I keep getting a segmentation fault while compiling a .csd file that works 95% of the time. It is recompiled multiple times in my program, and just occasionally throws up a segmentation fault and quits. I can run the same .csd fine from terminal
>
> While the overall c++ program is insanely complex, my implementation of csound is simple enough:
>
> static Csound csound;
>
> void exportWav (char* csdFileName) {
>
>     csound.Compile(csdFileName);
>     csound.Perform();
>     csound.Reset();
> }
>
> A debug directs me to this section of the Csound API:
>
>   virtual int Compile(char *csdName)
>   {
>     char  *argv[3];
>     argv[0] = (char*)"csound";
>     argv[1] = csdName;
>     argv[2] = (char*) 0;
>     return csoundCompile(csound, 2, &(argv[0]));     <--- Pointing specifically at this line
>   }
>
> This message also shows up in the terminal
>
> sfinit: cannot open /wav/testscore.wav
>
> I wondered if it was my implementation of Csound that was the problem, as I decided to try using it as a static variable that I just reset between uses, but I have tried using a Csound*, a static Csound* and just a Csound and all present the same issue.
>
> So it is clear that something is causing it to trip over during compilation, but I'm not sure what
>
> Cheers in advance for any advice you can offer
> ------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

Date2015-10-05 17:48
FromPeter Burgess
SubjectRe: [Cs-dev] Csound API Segmentation Fault
AttachmentsNone  None  
Ah right! sorry, I'm with you now. Thinking of the argv argc in the main function....

@Victor: I thought this is what you meant:

char* argv[] = {csdFileName};
csound.CompileCsd(1, argv[0]);

but there's no matching function call. I have also tried

csound.CompileCsd(1, &argv[0]);

as the documentation says a char** argv. What am I missing here? Also, is this way more stable than using the overload that just takes the char* fileName?

@Michael: Never used strdup before. Are you talking about using this on the fileName string to turn it into a char*?


On Mon, Oct 5, 2015 at 5:20 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
You just have to pass the CSD as one of the arguments. Argv is just an array of strings,
which you can create yourself when you need it. You always need to check the return value of the compilation function, because if there was an error, you should not proceed.

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

On 5 Oct 2015, at 17:12, Peter Burgess <pete.soundtechnician@gmail.com> wrote:

I'm not sure this will work for me, as the csd filename can change, and is decided by the c++ program, so argv does not contain the desired infomation (although I've only recently come to understand the use of argc and argv, so I may have this all wrong!)

While on the subject, is there a way of stopping csound crashing the program if this happens, allowing the chance to try to compile it again? Something like this:

    int result = -1;
    while (result != 0) {
        result = csound.Compile(csdFileName);
    }

The above compiles and runs but doesn't actually save the program from crashing

Cheers for your help!

Pete

On Mon, Oct 5, 2015 at 4:56 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
You can try using this function instead:

Csound::Compile(int argv, char *argc)

regards

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

> On 5 Oct 2015, at 16:48, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
>
> I keep getting a segmentation fault while compiling a .csd file that works 95% of the time. It is recompiled multiple times in my program, and just occasionally throws up a segmentation fault and quits. I can run the same .csd fine from terminal
>
> While the overall c++ program is insanely complex, my implementation of csound is simple enough:
>
> static Csound csound;
>
> void exportWav (char* csdFileName) {
>
>     csound.Compile(csdFileName);
>     csound.Perform();
>     csound.Reset();
> }
>
> A debug directs me to this section of the Csound API:
>
>   virtual int Compile(char *csdName)
>   {
>     char  *argv[3];
>     argv[0] = (char*)"csound";
>     argv[1] = csdName;
>     argv[2] = (char*) 0;
>     return csoundCompile(csound, 2, &(argv[0]));     <--- Pointing specifically at this line
>   }
>
> This message also shows up in the terminal
>
> sfinit: cannot open /wav/testscore.wav
>
> I wondered if it was my implementation of Csound that was the problem, as I decided to try using it as a static variable that I just reset between uses, but I have tried using a Csound*, a static Csound* and just a Csound and all present the same issue.
>
> So it is clear that something is causing it to trip over during compilation, but I'm not sure what
>
> Cheers in advance for any advice you can offer
> ------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel



Date2015-10-05 18:00
FromPeter Burgess
SubjectRe: [Cs-dev] Csound API Segmentation Fault
AttachmentsNone  None  
Oh, I've just realised an important bit of info I missed out, it always gets as far as setting up the options, so it must be reading the csd file fine. The options are identical for every run of the compilation, except the filename for the exported wav varies. I have run it a number of times and checked the csd file each time it fails, and found a strange connection between them.

The wav files are named things like 1.1, 2.4, 4.3, 2.6 etc...  for some reason, it always fails when the filename is either 2.1 or more commonly 4.1. So much does it hate exporting 4.1.wav, that 4.1 doesn't currently exist in the target folder.

Why on earth would it fail based on the export wav filename?

On Mon, Oct 5, 2015 at 5:48 PM, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
Ah right! sorry, I'm with you now. Thinking of the argv argc in the main function....

@Victor: I thought this is what you meant:

char* argv[] = {csdFileName};
csound.CompileCsd(1, argv[0]);

but there's no matching function call. I have also tried

csound.CompileCsd(1, &argv[0]);

as the documentation says a char** argv. What am I missing here? Also, is this way more stable than using the overload that just takes the char* fileName?

@Michael: Never used strdup before. Are you talking about using this on the fileName string to turn it into a char*?


On Mon, Oct 5, 2015 at 5:20 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
You just have to pass the CSD as one of the arguments. Argv is just an array of strings,
which you can create yourself when you need it. You always need to check the return value of the compilation function, because if there was an error, you should not proceed.

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

On 5 Oct 2015, at 17:12, Peter Burgess <pete.soundtechnician@gmail.com> wrote:

I'm not sure this will work for me, as the csd filename can change, and is decided by the c++ program, so argv does not contain the desired infomation (although I've only recently come to understand the use of argc and argv, so I may have this all wrong!)

While on the subject, is there a way of stopping csound crashing the program if this happens, allowing the chance to try to compile it again? Something like this:

    int result = -1;
    while (result != 0) {
        result = csound.Compile(csdFileName);
    }

The above compiles and runs but doesn't actually save the program from crashing

Cheers for your help!

Pete

On Mon, Oct 5, 2015 at 4:56 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
You can try using this function instead:

Csound::Compile(int argv, char *argc)

regards

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

> On 5 Oct 2015, at 16:48, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
>
> I keep getting a segmentation fault while compiling a .csd file that works 95% of the time. It is recompiled multiple times in my program, and just occasionally throws up a segmentation fault and quits. I can run the same .csd fine from terminal
>
> While the overall c++ program is insanely complex, my implementation of csound is simple enough:
>
> static Csound csound;
>
> void exportWav (char* csdFileName) {
>
>     csound.Compile(csdFileName);
>     csound.Perform();
>     csound.Reset();
> }
>
> A debug directs me to this section of the Csound API:
>
>   virtual int Compile(char *csdName)
>   {
>     char  *argv[3];
>     argv[0] = (char*)"csound";
>     argv[1] = csdName;
>     argv[2] = (char*) 0;
>     return csoundCompile(csound, 2, &(argv[0]));     <--- Pointing specifically at this line
>   }
>
> This message also shows up in the terminal
>
> sfinit: cannot open /wav/testscore.wav
>
> I wondered if it was my implementation of Csound that was the problem, as I decided to try using it as a static variable that I just reset between uses, but I have tried using a Csound*, a static Csound* and just a Csound and all present the same issue.
>
> So it is clear that something is causing it to trip over during compilation, but I'm not sure what
>
> Cheers in advance for any advice you can offer
> ------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel




Date2015-10-05 18:09
FromPeter Burgess
SubjectRe: [Cs-dev] Csound API Segmentation Fault
AttachmentsNone  None  
I don't know if this is more or less strange, but if I change the start point, the program trips up on a different filename. Currently, it's repeatedly tripping up on 7.1.wav

I'm stumped. Could something in my program be clashing with csound at a specific interval after the start?

On Mon, Oct 5, 2015 at 6:00 PM, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
Oh, I've just realised an important bit of info I missed out, it always gets as far as setting up the options, so it must be reading the csd file fine. The options are identical for every run of the compilation, except the filename for the exported wav varies. I have run it a number of times and checked the csd file each time it fails, and found a strange connection between them.

The wav files are named things like 1.1, 2.4, 4.3, 2.6 etc...  for some reason, it always fails when the filename is either 2.1 or more commonly 4.1. So much does it hate exporting 4.1.wav, that 4.1 doesn't currently exist in the target folder.

Why on earth would it fail based on the export wav filename?

On Mon, Oct 5, 2015 at 5:48 PM, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
Ah right! sorry, I'm with you now. Thinking of the argv argc in the main function....

@Victor: I thought this is what you meant:

char* argv[] = {csdFileName};
csound.CompileCsd(1, argv[0]);

but there's no matching function call. I have also tried

csound.CompileCsd(1, &argv[0]);

as the documentation says a char** argv. What am I missing here? Also, is this way more stable than using the overload that just takes the char* fileName?

@Michael: Never used strdup before. Are you talking about using this on the fileName string to turn it into a char*?


On Mon, Oct 5, 2015 at 5:20 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
You just have to pass the CSD as one of the arguments. Argv is just an array of strings,
which you can create yourself when you need it. You always need to check the return value of the compilation function, because if there was an error, you should not proceed.

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

On 5 Oct 2015, at 17:12, Peter Burgess <pete.soundtechnician@gmail.com> wrote:

I'm not sure this will work for me, as the csd filename can change, and is decided by the c++ program, so argv does not contain the desired infomation (although I've only recently come to understand the use of argc and argv, so I may have this all wrong!)

While on the subject, is there a way of stopping csound crashing the program if this happens, allowing the chance to try to compile it again? Something like this:

    int result = -1;
    while (result != 0) {
        result = csound.Compile(csdFileName);
    }

The above compiles and runs but doesn't actually save the program from crashing

Cheers for your help!

Pete

On Mon, Oct 5, 2015 at 4:56 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
You can try using this function instead:

Csound::Compile(int argv, char *argc)

regards

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

> On 5 Oct 2015, at 16:48, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
>
> I keep getting a segmentation fault while compiling a .csd file that works 95% of the time. It is recompiled multiple times in my program, and just occasionally throws up a segmentation fault and quits. I can run the same .csd fine from terminal
>
> While the overall c++ program is insanely complex, my implementation of csound is simple enough:
>
> static Csound csound;
>
> void exportWav (char* csdFileName) {
>
>     csound.Compile(csdFileName);
>     csound.Perform();
>     csound.Reset();
> }
>
> A debug directs me to this section of the Csound API:
>
>   virtual int Compile(char *csdName)
>   {
>     char  *argv[3];
>     argv[0] = (char*)"csound";
>     argv[1] = csdName;
>     argv[2] = (char*) 0;
>     return csoundCompile(csound, 2, &(argv[0]));     <--- Pointing specifically at this line
>   }
>
> This message also shows up in the terminal
>
> sfinit: cannot open /wav/testscore.wav
>
> I wondered if it was my implementation of Csound that was the problem, as I decided to try using it as a static variable that I just reset between uses, but I have tried using a Csound*, a static Csound* and just a Csound and all present the same issue.
>
> So it is clear that something is causing it to trip over during compilation, but I'm not sure what
>
> Cheers in advance for any advice you can offer
> ------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel





Date2015-10-05 18:48
FromVictor Lazzarini
SubjectRe: [Cs-dev] Csound API Segmentation Fault
AttachmentsNone  None  
No, the array of strings should have two items. The first one should be the string Csound, and the second the name of your CSD.

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

On 5 Oct 2015, at 17:48, Peter Burgess <pete.soundtechnician@gmail.com> wrote:

Ah right! sorry, I'm with you now. Thinking of the argv argc in the main function....

@Victor: I thought this is what you meant:

char* argv[] = {csdFileName};
csound.CompileCsd(1, argv[0]);

but there's no matching function call. I have also tried

csound.CompileCsd(1, &argv[0]);

as the documentation says a char** argv. What am I missing here? Also, is this way more stable than using the overload that just takes the char* fileName?

@Michael: Never used strdup before. Are you talking about using this on the fileName string to turn it into a char*?


On Mon, Oct 5, 2015 at 5:20 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
You just have to pass the CSD as one of the arguments. Argv is just an array of strings,
which you can create yourself when you need it. You always need to check the return value of the compilation function, because if there was an error, you should not proceed.

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

On 5 Oct 2015, at 17:12, Peter Burgess <pete.soundtechnician@gmail.com> wrote:

I'm not sure this will work for me, as the csd filename can change, and is decided by the c++ program, so argv does not contain the desired infomation (although I've only recently come to understand the use of argc and argv, so I may have this all wrong!)

While on the subject, is there a way of stopping csound crashing the program if this happens, allowing the chance to try to compile it again? Something like this:

    int result = -1;
    while (result != 0) {
        result = csound.Compile(csdFileName);
    }

The above compiles and runs but doesn't actually save the program from crashing

Cheers for your help!

Pete

On Mon, Oct 5, 2015 at 4:56 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
You can try using this function instead:

Csound::Compile(int argv, char *argc)

regards

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

> On 5 Oct 2015, at 16:48, Peter Burgess <pete.soundtechnician@gmail.com> wrote:
>
> I keep getting a segmentation fault while compiling a .csd file that works 95% of the time. It is recompiled multiple times in my program, and just occasionally throws up a segmentation fault and quits. I can run the same .csd fine from terminal
>
> While the overall c++ program is insanely complex, my implementation of csound is simple enough:
>
> static Csound csound;
>
> void exportWav (char* csdFileName) {
>
>     csound.Compile(csdFileName);
>     csound.Perform();
>     csound.Reset();
> }
>
> A debug directs me to this section of the Csound API:
>
>   virtual int Compile(char *csdName)
>   {
>     char  *argv[3];
>     argv[0] = (char*)"csound";
>     argv[1] = csdName;
>     argv[2] = (char*) 0;
>     return csoundCompile(csound, 2, &(argv[0]));     <--- Pointing specifically at this line
>   }
>
> This message also shows up in the terminal
>
> sfinit: cannot open /wav/testscore.wav
>
> I wondered if it was my implementation of Csound that was the problem, as I decided to try using it as a static variable that I just reset between uses, but I have tried using a Csound*, a static Csound* and just a Csound and all present the same issue.
>
> So it is clear that something is causing it to trip over during compilation, but I'm not sure what
>
> Cheers in advance for any advice you can offer
> ------------------------------------------------------------------------------
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel

------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel