[Cs-dev] circular buffer implementation is broken
Date | 2013-06-24 13:21 |
From | Victor Lazzarini |
Subject | [Cs-dev] circular buffer implementation is broken |
Hi Andres, I think your changes have broke the circular buffer mechanism. I tried the auhal module, which uses it and it's not working anymore, it seems to be stuck somehow. Could you fix it back? The circular buffer is used in various places, in the realtime mode, so it's crucial that it works at least as before. Regards Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2013-06-24 16:50 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
Hi Victor, I'll fix it, but I'd need to know what's broken...Andrés On Mon, Jun 24, 2013 at 5:21 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: Hi Andres, |
Date | 2013-06-24 16:55 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
OK, I see I missed changing the function signature in a few places, sorry about that. Now fixing. Cheers, Andrés On Mon, Jun 24, 2013 at 8:50 AM, Andres Cabrera <mantaraya36@gmail.com> wrote:
|
Date | 2013-06-24 17:11 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
It builds OK, but it doesn't work. The circular buffer is used in lots of places, that is why I was worried about these changes. If you are not sure, I would vote for reverting to the old code and do these changes later. Or you could keep the old implementation for all the internal uses and add the new for channels and API. Victor On 24 Jun 2013, at 16:50, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-24 17:18 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
OK, I'll have a try when you're done. On 24 Jun 2013, at 16:55, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-24 18:01 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
I think I have fixed it. I have tested with the diskin2 opcode which I think should use the circular buffer and it's sounding fine. Please let me know if it's still not working for you and if possible provide a test case. (I can't use auhal here right now). Cheers,Andrés On Mon, Jun 24, 2013 at 9:18 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-06-24 20:00 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
What about the asynchronous file reading and writing functions, did you make sure they are working too? They depend on the circular buffer. On 24 Jun 2013, at 18:01, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-24 20:06 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
I tested and I found two problems: 1) realtime audio with auhal has loads of dropouts, it's very choppy, not usable at all 2) On ctrl-C, I get ^CCsound tidy up: Interrupt csound(64142,0x7fff7057ccc0) malloc: *** error for object 0x1008db808: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug Csound tidy up: Abort trap which is also new. Victor On 24 Jun 2013, at 18:01, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-24 21:19 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
I've tested diskin2 in realtime mode (which uses circular buffer) and it's crackly too. I suspect fout.c etc will also be the same. Victor On 24 Jun 2013, at 20:06, Victor Lazzarini wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-25 04:36 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
I think that I've got it this time, but I can't currently test as csound crashes when I try to use Cheers,realtime mode. It will crash both when using the API and when running csound command line: $ ./csound ~/Desktop/diskin2.csd --realtime virtual_keyboard real time MIDI plugin for Csound 0dBFS level = 32768.0 Csound version 6.00rc3 (double samples) Jun 24 2013 libsndfile-1.0.25 UnifiedCSD: /home/andres/Desktop/diskin2.csd STARTING FILE Creating options Creating orchestra Creating score rtaudio: ALSA module enabled rtmidi: ALSA module enabled Parsing successful! Csound tidy up: Segmentation fault end of score. overall amps: 0.00000 0.00000 overall samples out of range: 0 0 0 errors in performance Elapsed time at end of performance: real: 0.252s, CPU: 0.000s Segmentation fault Andrés On Mon, Jun 24, 2013 at 1:19 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-06-25 08:06 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
I've fixed those crashes yesterday, you can pull and try it. i'll try it later. Victor On 25 Jun 2013, at 04:36, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-25 08:28 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
you can pull the latest to try your fix. Or you can push your fixes (they're not there yet). On 25 Jun 2013, at 04:36, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-25 17:00 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
Thanks, it's now working for me and I tested diskin2 with --realtime and it's not choppy. Can you confirm it works for you too? Cheers, Andrés
On Tue, Jun 25, 2013 at 12:28 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-06-25 21:48 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
OK, now it's WriteAsync used by fout.c that is broken: Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x00000001057c9000 0x00007fffffe007c5 in __memcpy () (gdb) bt #0 0x00007fffffe007c5 in __memcpy () #1 0x0000000100033157 in csoundWriteCircularBuffer (csound=<value temporarily unavailable, due to optimizations>, p=<value temporarily unavailable, due to optimizations>, in=0x104817010, items=<value temporarily unavailable, due to optimizations>) at /Users/victor/src/csound6/InOut/circularbuffer.c:118 with this code (in --realtime) instr 1 a1 oscili 0.5, 440 fout "sin.wav",2, a1 out a1 endin On 25 Jun 2013, at 17:00, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-25 23:50 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
Hi, I can't reproduce this here. I've tried your code with --realtime, but the generated file is OK and Csound exits cleanly.I even ran under valgrind with no issues on that front (it did report other issues on cleanup which I'm attaching below). Andrés On Tue, Jun 25, 2013 at 1:48 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-06-26 00:03 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
I don't know, but it is crashing constantly here, and I have your latest code, line 118 in circularbuffer.c (as below). Valgrind also barfs: ==73025== More than 100 errors detected. Subsequent errors ==73025== will still be recorded, but in less detail than before. ==73025== ==73025== More than 10000000 total errors detected. I'm not reporting any more. ==73025== Final error counts will be inaccurate. Go fix your program! ==73025== Rerun with --error-limit=no to disable this cutoff. Note ==73025== that errors may occur in your program without prior warning from ==73025== Valgrind, because errors are no longer being displayed. ==73025== So I am not sure. Victor On 25 Jun 2013, at 23:50, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-26 00:23 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
I am just looking at the code. Two bits are suspicious: 77: memcpy((char *) out, &(buffer[elemsize * rp]), itemsread * elemsize); can this line read beyond the buffer limits? If for instance rp += itemsread; if (rp >= numelem) is true, isn't it the case that the memcpy would have accessed beyond the buffer? And then when rp is wrapped around the beginning of the buffer is never read? 117: for(i=0; i < itemswrite; i++){ memcpy(&(buffer[elemsize * wp++]), ((char *) in) + (i * elemsize), itemswrite* elemsize); if(wp == numelem) wp = 0; } can possibly write beyond the buffer, because itemswrite* elemsize is too much to write each time. Shouldn't this be just elemsize (ie you are writing element by element)? Victor On 26 Jun 2013, at 00:03, Victor Lazzarini wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-26 00:32 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
OK, I've made what I thought were the right fixes for these lines, and pushed to GIT. Could you review? It's not crashing anymore. Victor On 26 Jun 2013, at 00:23, Victor Lazzarini wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-26 03:22 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
So strange! I had already fixed that yesterday and it's in git! It got lost before it got to you... Anyway, thanks for looking at it. How could it have got lost? I can't find any commit in between that touched those files!On Tue, Jun 25, 2013 at 4:32 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-06-26 08:04 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
yes, I was wondering about that, but I had pulled it after you said. I also kept pulling but there was nothing new in the repo. On 26 Jun 2013, at 03:22, Andres Cabrera wrote:
Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie |
Date | 2013-06-26 14:59 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
So strange. I'm just worried that I can't understand why it disappeared... Cheers, Andrés On Wed, Jun 26, 2013 at 12:04 AM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
|
Date | 2013-06-26 16:38 |
From | Justin Smith |
Subject | Re: [Cs-dev] circular buffer implementation is broken |
Attachments | None None |
you could try comparing the output of "git log" in your repo on disk to the "git log" output in a fresh checkout from the origin - that should expose any discrepancies On Wed, Jun 26, 2013 at 6:59 AM, Andres Cabrera <mantaraya36@gmail.com> wrote:
|