[Cs-dev] Problem with csoundTabbleCopyOut()
Date | 2014-03-14 14:45 |
From | Rory Walsh |
Subject | [Cs-dev] Problem with csoundTabbleCopyOut() |
Attachments | test.cpp example1.csd None None |
Attached are the source and csd file that will produce the problem.
Backtrace: #0 __memcpy_ssse3_back () at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579 #1 0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1, ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50 #2 0x0000000000404e12 in Csound::TableCopyOut(int, float*) () #3 0x0000000000403779 in main () |
Date | 2014-03-19 14:59 |
From | Rory Walsh |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
Attachments | None None |
I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy: memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT))); The values read: These addresses appear to be valid, but how would one find out for sure?ptable = 0x4035c0 len = 1024 ftab = 0x7a2d50 On 14 March 2014 14:45, Rory Walsh <rorywalsh@ear.ie> wrote:
|
Date | 2014-03-19 15:16 |
From | Rory Walsh |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
Attachments | None None |
I thought the following code might catch something but Csound runs through it without any issue. I'm happy to try out any suggestions :) I also tried creating the function table in instr0 but that didn't help either. MYFLT tmp; int i=0; for (i = 0; i < len; i++) { tmp = ptable[i]; tmp = ftab[i]; }
On 19 March 2014 14:59, Rory Walsh <rorywalsh@ear.ie> wrote:
|
Date | 2014-03-19 15:18 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
ptable = 0x0 is the problem (see #1). ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 14 Mar 2014, at 14:45, Rory Walsh |
Date | 2014-03-19 15:19 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
MYFLT* temp = 0; int tableSize = csound->TableLength(1); csound->TableCopyOut(1, temp); You need memory to copy into. Try allocating it. ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 19 Mar 2014, at 14:59, Rory Walsh |
Date | 2014-03-19 15:34 |
From | Rory Walsh |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
Attachments | None None |
That gives the same error. I also just tried explicitly allocating enough space ala: int tableSize = csound->TableLength(1); MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT)); csound->TableCopyOut(1, temp); but that gives a whole host of new errors: 0 0x00007ffff700e425 __GI_raise ../nptl/sysdeps/unix/sysv/linux/raise.c 64 1 0x00007ffff7011b8b __GI_abort abort.c 91 2 0x00007ffff704c39e __libc_message ../sysdeps/unix/sysv/linux/libc_fatal.c 201 3 0x00007ffff7056b96 malloc_printerr malloc.c 5039 4 0x00007ffff790bd03 mfree /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c 157 5 0x00007ffff79042c1 orcompact /home/rory/sourcecode/csound-csound6-git/Engine/insert.c 813 6 0x00007ffff790f714 csoundCleanup /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c 447 7 0x00007ffff7a61b48 reset /home/rory/sourcecode/csound-csound6-git/Top/csound.c 2646 8 0x00007ffff7a5e64c csoundDestroy /home/rory/sourcecode/csound-csound6-git/Top/csound.c 1212 9 0x000000000040551f Csound::~Csound() 10 0x0000000000405552 Csound::~Csound() 11 0x00000000004037f6 main I'm not sure why ptable was 0x0 in my first report from a few days ago, it certainly seems valid now. I think I might have tried initialized it to something in an attempt go bypass this problem. On 19 March 2014 15:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: MYFLT* temp = 0; |
Date | 2014-03-19 15:57 |
From | jpff@cs.bath.ac.uk |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
Attachments | None |
Date | 2014-03-19 16:00 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
I don’t know: your test program works here when I allocate memory. It prints out the table too. int main(int argc, char *argv[]) { /*Create an instance of Csound*/ Csound* csound = new Csound; csound->Compile("example1.csd"); csound->PerformKsmps(); int tableSize = csound->TableLength(1); printf("%d \n", tableSize); MYFLT *temp = new MYFLT[tableSize]; csound->TableCopyOut(1, temp); for(int i=0;i |
Date | 2014-03-19 16:06 |
From | Rory Walsh |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
Attachments | None None |
Weird. It works when I use your C++ method of allocation, but causes problems when I use malloc? Anyhow, that should hopefully get me past that problem. Now to try it on a full-blown scale.. On 19 March 2014 16:00, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: I don’t know: your test program works here when I allocate memory. It prints out the table too. |
Date | 2014-03-19 17:51 |
From | Rory Walsh |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
Attachments | example1.csd None None |
So I'm looking for a way to access values from tables that have been resized, and in a threadsafe manor. As I need to dynamically alter my temp array I tried using a std::vector which I resize between calls to csoundPerformKsmps(). But as soon as I resize the table it gives me the same error as I was getting to start with. I've attached a csd file that uses John's ftresize opcodes and runs fine in Csound. Coupled with the code from below it will crash at the memcpy line in csoundTableCopyOut() I pointed to before. Any ideas on what I might be doing wrong? std::vector allocates memory when resize is called, and Btw, I also tried with std::vector::data() which returns a direct pointer to the vector's internal array but that results in the same problem. Any ideas?std::vector<MYFLT> temp (1024); while(csound->PerformKsmps()==0){ tableSize = csound->TableLength(1); if(testTableSize!=tableSize){ testTableSize = tableSize; csound->Message("Table size is now: %d\n", testTableSize); } temp.resize(tableSize); csound->TableCopyOut(1, &temp[0]); } On 19 March 2014 16:06, Rory Walsh <rorywalsh@ear.ie> wrote:
|
Date | 2014-03-19 19:18 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
I don’t know again. This works here: std::vector |
Date | 2014-03-19 19:23 |
From | Rory Walsh |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
Attachments | None None |
And you are using the attached .csd with the continuously changing ftables? Also, are you making those 4 calls after every csoundPerformKsmp()? I take it you are on OSX? I haven't tried this on Windows. Still trying to get it to work on Linux. Hmm.. On 19 March 2014 19:18, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: I don’t know again. This works here: |
Date | 2014-03-19 19:33 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
yes, no crashes with this program, on OSX int main(int argc, char *argv[]) { /*Create an instance of Csound*/ Csound* csound = new Csound; csound->Compile("example1.csd"); csound->PerformKsmps(); int testTableSize, tableSize; std::vector |
Date | 2014-03-19 19:36 |
From | Rory Walsh |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
Attachments | None None |
I'm stumped. I'm using the latest develop code from git. I'll try it out on windows and see how it goes. For now I'm changing tact. I think it probably better to write recordings to a temp file on disk, and then load that into a function table if users wish to edit it. I would still like the option of resizing tables on the fly though. But I can work around it for now. On 19 March 2014 19:33, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: yes, no crashes with this program, on OSX |
Date | 2014-03-19 22:53 |
From | Steven Yi |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
Just to double-check, did you define MYFLT=double? On Wed, Mar 19, 2014 at 3:36 PM, Rory Walsh |
Date | 2014-03-19 23:25 |
From | Rory Walsh |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
Attachments | None None |
I didn't for the basic example I was testing, but I do for Cabbage and it bombs there too. So I just tried now the following command line, but no luck: g++ test.cpp -I../include -L. -lcsound64 -D "USE_DOUBLE=1" -g -o testApp I'll try windows tomorrow and see if I get any different results. On 19 March 2014 22:53, Steven Yi <stevenyi@gmail.com> wrote: Just to double-check, did you define MYFLT=double? |
Date | 2014-03-20 00:52 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
It turns out that the resize opcode had not been updated to the new table code. I did that, and table copy works now. But with the resize, the ftable pointer is different and tab/tabw could not find and crashed. So I updated these to find the table at perf time. Probably needs to be done with all other table readers/writers. in git develop now. ======================== Dr Victor Lazzarini Senior Lecturer NUI Maynooth, Ireland victor dot lazzarini at nuim dot ie On 19 Mar 2014, at 23:25, Rory Walsh |
Date | 2014-03-20 08:59 |
From | Rory Walsh |
Subject | Re: [Cs-dev] Problem with csoundTabbleCopyOut() |
Attachments | None None |
Works now. Thanks Victor! On 20 March 2014 00:52, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: It turns out that the resize opcode had not been updated to the new table code. I did that, and table copy works now. |