[Cs-dev] Crash when stopping Csound using C API
Date | 2011-03-21 13:47 |
From | Joseph Sanger |
Subject | [Cs-dev] Crash when stopping Csound using C API |
Dear List, As suggested, I'm reposting this to csound-devel. I'm using Ubuntu studio. I've successfully built csound 5.13 on 64-bit, using the old parser, doubles etc. It works fine, and I think the memory bug is fixed now, so thank you. I am writing a host program written in C, with a TUI written using ncurses, which sends strings and contol data to a large orchestra using chnset/chnget and the csound c API functions. It uses a lot of chnset/chnget channels (hundreds, in a reasonably large patch). It works, but when the performance is stopped and csoundReset is called, it often crashes and prints a backtrace (an example of which I've pasted below). "janko" is the name of my host app. I've just reinstalled 5.12 from the Ubuntu repos to check it again, and it does crash occasionally with the same "double free or corruption" error when stopping csound - more often with larger orchestras. If I run the same input .csd from the command line, then it seems to work fine - but I can't check thoroughly as it's not receiving any data from the software bus, which it needs to make noises. The host program is getting larger and larger, and I'm not a very experienced programmer, so the error could well be mine, many apologies in advance if so! Thanks as always, Joe SECTION 1: *** glibc detected *** janko: double free or corruption (!prev): 0x000000000194f390 *** ======= Backtrace: ========= /lib/libc.so.6(+0x774b6)[0x7f6d0e4f84b6] /lib/libc.so.6(cfree+0x73)[0x7f6d0e4fec83] /usr/local/lib/libcsound64.so.5.2(csoundCleanup+0x117)[0x7f6d0ea7c417] /usr/local/lib/libcsound64.so.5.2(csoundReset+0xe)[0x7f6d0eaef02e] janko[0x409721] /lib/libpthread.so.0(+0x7971)[0x7f6d0e006971] /lib/libc.so.6(clone+0x6d)[0x7f6d0e56792d] ======= Memory map: ======== 00400000-0040c000 r-xp 00000000 08:04 9175375 /mnt/music/csound/c_synth/synth 0060b000-0060c000 r--p 0000b000 08:04 9175375 /mnt/music/csound/c_synth/synth 0060c000-0060d000 rw-p 0000c000 08:04 9175375 /mnt/music/csound/c_synth/synth 011a2000-019b2000 rw-p 00000000 00:00 0 [heap] 7f6cf8000000-7f6cf80e4000 rw-p 00000000 00:00 0 7f6cf80e4000-7f6cfc000000 ---p 00000000 00:00 0 7f6cfdaf7000-7f6cfdaf8000 ---p 00000000 00:00 0 7f6cfdaf8000-7f6cfe2f8000 rw-p 00000000 00:00 0 7f6cfe2f8000-7f6d0315f000 rw-s 00000000 00:10 14593 /dev/shm/jack-1000-0 7f6d0315f000-7f6d03176000 r-xp 00000000 08:02 24905098 /lib/libnsl-2.12.1.so 7f6d03176000-7f6d03375000 ---p 00017000 08:02 24905098 /lib/libnsl-2.12.1.so 7f6d03375000-7f6d03376000 r--p 00016000 08:02 24905098 /lib/libnsl-2.12.1.so 7f6d03376000-7f6d03377000 rw-p 00017000 08:02 24905098 /lib/libnsl-2.12.1.so 7f6d03377000-7f6d03379000 rw-p 00000000 00:00 0 7f6d03379000-7f6d033b9000 r-xp 00000000 08:02 24904760 /lib/libdbus-1.so.3.5.2 7f6d033b9000-7f6d035b9000 ---p 00040000 08:02 24904760 /lib/libdbus-1.so.3.5.2 7f6d035b9000-7f6d035ba000 r--p 00040000 08:02 24904760 /lib/libdbus-1.so.3.5.2 7f6d035ba000-7f6d035bb000 rw-p 00041000 08:02 24904760 /lib/libdbus-1.so.3.5.2 7f6d035bb000-7f6d035c4000 r-xp 00000000 08:02 24907235 /lib/libwrap.so.0.7.6 7f6d035c4000-7f6d037c3000 ---p 00009000 08:02 24907235 /lib/libwrap.so.0.7.6 7f6d037c3000-7f6d037c4000 r--p 00008000 08:02 24907235 /lib/libwrap.so.0.7.6 7f6d037c4000-7f6d037c5000 rw-p 00009000 08:02 24907235 /lib/libwrap.so.0.7.6 7f6d037c5000-7f6d037c6000 rw-p 00000000 00:00 0 7f6d037c6000-7f6d037cb000 r-xp 00000000 08:02 9182818 /usr/lib/libXdmcp.so.6.0.0 7f6d037cb000-7f6d039ca000 ---p 00005000 08:02 9182818 /usr/lib/libXdmcp.so.6.0.0 7f6d039ca000-7f6d039cb000 r--p 00004000 08:02 9182818 /usr/lib/libXdmcp.so.6.0.0 7f6d039cb000-7f6d039cc000 rw-p 00005000 08:02 9182818 /usr/lib/libXdmcp.so.6.0.0 7f6d039cc000-7f6d039ce000 r-xp 00000000 08:02 9182816 /usr/lib/libXau.so.6.0.0 7f6d039ce000-7f6d03bcd000 ---p 00002000 08:02 9182816 /usr/lib/libXau.so.6.0.0 7f6d03bcd000-7f6d03bce000 r--p 00001000 08:02 9182816 /usr/lib/libXau.so.6.0.0 7f6d03bce000-7f6d03bcf000 rw-p 00002000 08:02 9182816 /usr/lib/libXau.so.6.0.0 7f6d03bcf000-7f6d03bdd000 r-xp 00000000 08:02 9182983 /usr/lib/libXi.so.6.1.0 7f6d03bdd000-7f6d03ddd000 ---p 0000e000 08:02 9182983 /usr/lib/libXi.so.6.1.0 7f6d03ddd000-7f6d03dde000 r--p 0000e000 08:02 9182983 /usr/lib/libXi.so.6.1.0 7f6d03dde000-7f6d03ddf000 rw-p 0000f000 08:02 9182983 /usr/lib/libXi.so.6.1.0 7f6d03ddf000-7f6d03df0000 r-xp 00000000 08:02 9182894 /usr/lib/libXext.so.6.4.0 7f6d03df0000-7f6d03fef000 ---p 00011000 08:02 9182894 /usr/lib/libXext.so.6.4.0 7f6d03fef000-7f6d03ff0000 r--p 00010000 08:02 9182894 /usr/lib/libXext.so.6.4.0 7f6d03ff0000-7f6d03ff1000 rw-p 00011000 08:02 9182894 /usr/lib/libXext.so.6.4.0 7f6d03ff1000-7f6d03ff4000 r-xp 00000000 08:02 24905211 /lib/libuuid.so.1.3.0 7f6d03ff4000-7f6d041f4000 ---p 00003000 08:02 24905211 /lib/libuuid.so.1.3.0 7f6d041f4000-7f6d041f5000 r--p 00003000 08:02 24905211 /lib/libuuid.so.1.3.0 7f6d041f5000-7f6d041f6000 rw-p 00004000 08:02 24905211 /lib/libuuid.so.1.3.0 7f6d041f6000-7f6d04240000 r-xp 00000000 08:02 9181100 /usr/lib/libpulsecommon-0.9.21.so 7f6d04240000-7f6d04440000 ---p 0004a000 08:02 9181100 /usr/lib/libpulsecommon-0.9.21.so 7f6d04440000-7f6d04441000 r--p 0004a000 08:02 9181100 /usr/lib/libpulsecommon-0.9.21.so 7f6d04441000-7f6d04442000 rw-p 0004b000 08:02 9181100 /usr/lib/libpulsecommon-0.9.21.so 7f6d04442000-7f6d0445d000 r-xp 00000000 08:02 9182820 /usr/lib/libxcb.so.1.1.0 7f6d0445d000-7f6d0465d000 ---p 0001b000 08:02 9182820 /usr/lib/libxcb.so.1.1.0 7f6d0465d000-7f6d0465e000 r--p 0001b000 08:02 9182820 /usr/lib/libxcb.so.1.1.0 7f6d0465e000-7f6d0465f000 rw-p 0001c000 08:02 9182820 /usr/lib/libxcb.so.1.1.0 7f6d0465f000-7f6d04662000 r-xp 00000000 08:02 9183333 /usr/lib/libxcb-atom.so.1.0.0 7f6d04662000-7f6d04862000 ---p 00003000 08:02 9183333 /usr/lib/libxcb-atom.so.1.0.0 7f6d04862000-7f6d04863000 r--p 00003000 08:02 9183333 /usr/lib/libxcb-atom.so.1.0.0 7f6d04863000-7f6d04864000 rw-p 00004000 08:02 9183333 /usr/lib/libxcb-atom.so.1.0.0 7f6d04864000-7f6d04869000 r-xp 00000000 08:02 9183539 /usr/lib/libXtst.so.6.1.0 7f6d04869000-7f6d04a69000 ---p 00005000 08:02 9183539 /usr/lib/libXtst.so.6.1.0 7f6d04a69000-7f6d04a6a000 r--p 00005000 08:02 9183539 /usr/lib/libXtst.so.6.1.0Aborted -- Joseph Sanger Blueberry Eikaiwa www.bbeikaiwa.com ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2011-03-21 15:15 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Crash when stopping Csound using C API |
Hi Joseph, the easiest thing for us would be if you could try isolating the problem and giving us an example we can work with. Various frontends use the bus, so if there was a bug in it, we would have noticed it already. But you never know. Alternatively, you might want to use the "invalue/outvalue" system instead of chn opcodes and see if it works better. Victor On 21 Mar 2011, at 13:47, Joseph Sanger wrote: > Dear List, > > As suggested, I'm reposting this to csound-devel. > > I'm using Ubuntu studio. I've successfully built csound 5.13 on 64- > bit, > using the old parser, doubles etc. It works fine, and I think the > memory > bug is fixed now, so thank you. > > I am writing a host program written in C, with a TUI written using > ncurses, which sends strings and contol data to a large orchestra > using > chnset/chnget and the csound c API functions. It uses a lot of > chnset/chnget channels (hundreds, in a reasonably large patch). It > works, but when the performance is stopped and csoundReset is > called, it > often crashes and prints a backtrace (an example of which I've pasted > below). "janko" is the name of my host app. > > I've just reinstalled 5.12 from the Ubuntu repos to check it again, > and > it does crash occasionally with the same "double free or corruption" > error when stopping csound - more often with larger orchestras. > > If I run the same input .csd from the command line, then it seems to > work fine - but I can't check thoroughly as it's not receiving any > data > from the software bus, which it needs to make noises. > > The host program is getting larger and larger, and I'm not a very > experienced programmer, so the error could well be mine, many > apologies > in advance if so! > > Thanks as always, > > Joe > > > > > > > SECTION 1: > *** glibc detected *** janko: double free or corruption (!prev): > 0x000000000194f390 *** > ======= Backtrace: ========= > /lib/libc.so.6(+0x774b6)[0x7f6d0e4f84b6] > /lib/libc.so.6(cfree+0x73)[0x7f6d0e4fec83] > /usr/local/lib/libcsound64.so.5.2(csoundCleanup+0x117)[0x7f6d0ea7c417] > /usr/local/lib/libcsound64.so.5.2(csoundReset+0xe)[0x7f6d0eaef02e] > janko[0x409721] > /lib/libpthread.so.0(+0x7971)[0x7f6d0e006971] > /lib/libc.so.6(clone+0x6d)[0x7f6d0e56792d] > ======= Memory map: ======== > 00400000-0040c000 r-xp 00000000 08:04 9175375 > /mnt/music/csound/c_synth/synth > 0060b000-0060c000 r--p 0000b000 08:04 9175375 > /mnt/music/csound/c_synth/synth > 0060c000-0060d000 rw-p 0000c000 08:04 9175375 > /mnt/music/csound/c_synth/synth > 011a2000-019b2000 rw-p 00000000 00:00 0 > [heap] > 7f6cf8000000-7f6cf80e4000 rw-p 00000000 00:00 0 > 7f6cf80e4000-7f6cfc000000 ---p 00000000 00:00 0 > 7f6cfdaf7000-7f6cfdaf8000 ---p 00000000 00:00 0 > 7f6cfdaf8000-7f6cfe2f8000 rw-p 00000000 00:00 0 > 7f6cfe2f8000-7f6d0315f000 rw-s 00000000 00:10 14593 > /dev/shm/jack-1000-0 > 7f6d0315f000-7f6d03176000 r-xp 00000000 08:02 24905098 > /lib/libnsl-2.12.1.so > 7f6d03176000-7f6d03375000 ---p 00017000 08:02 24905098 > /lib/libnsl-2.12.1.so > 7f6d03375000-7f6d03376000 r--p 00016000 08:02 24905098 > /lib/libnsl-2.12.1.so > 7f6d03376000-7f6d03377000 rw-p 00017000 08:02 24905098 > /lib/libnsl-2.12.1.so > 7f6d03377000-7f6d03379000 rw-p 00000000 00:00 0 > 7f6d03379000-7f6d033b9000 r-xp 00000000 08:02 24904760 > /lib/libdbus-1.so.3.5.2 > 7f6d033b9000-7f6d035b9000 ---p 00040000 08:02 24904760 > /lib/libdbus-1.so.3.5.2 > 7f6d035b9000-7f6d035ba000 r--p 00040000 08:02 24904760 > /lib/libdbus-1.so.3.5.2 > 7f6d035ba000-7f6d035bb000 rw-p 00041000 08:02 24904760 > /lib/libdbus-1.so.3.5.2 > 7f6d035bb000-7f6d035c4000 r-xp 00000000 08:02 24907235 > /lib/libwrap.so.0.7.6 > 7f6d035c4000-7f6d037c3000 ---p 00009000 08:02 24907235 > /lib/libwrap.so.0.7.6 > 7f6d037c3000-7f6d037c4000 r--p 00008000 08:02 24907235 > /lib/libwrap.so.0.7.6 > 7f6d037c4000-7f6d037c5000 rw-p 00009000 08:02 24907235 > /lib/libwrap.so.0.7.6 > 7f6d037c5000-7f6d037c6000 rw-p 00000000 00:00 0 > 7f6d037c6000-7f6d037cb000 r-xp 00000000 08:02 9182818 > /usr/lib/libXdmcp.so.6.0.0 > 7f6d037cb000-7f6d039ca000 ---p 00005000 08:02 9182818 > /usr/lib/libXdmcp.so.6.0.0 > 7f6d039ca000-7f6d039cb000 r--p 00004000 08:02 9182818 > /usr/lib/libXdmcp.so.6.0.0 > 7f6d039cb000-7f6d039cc000 rw-p 00005000 08:02 9182818 > /usr/lib/libXdmcp.so.6.0.0 > 7f6d039cc000-7f6d039ce000 r-xp 00000000 08:02 9182816 > /usr/lib/libXau.so.6.0.0 > 7f6d039ce000-7f6d03bcd000 ---p 00002000 08:02 9182816 > /usr/lib/libXau.so.6.0.0 > 7f6d03bcd000-7f6d03bce000 r--p 00001000 08:02 9182816 > /usr/lib/libXau.so.6.0.0 > 7f6d03bce000-7f6d03bcf000 rw-p 00002000 08:02 9182816 > /usr/lib/libXau.so.6.0.0 > 7f6d03bcf000-7f6d03bdd000 r-xp 00000000 08:02 9182983 > /usr/lib/libXi.so.6.1.0 > 7f6d03bdd000-7f6d03ddd000 ---p 0000e000 08:02 9182983 > /usr/lib/libXi.so.6.1.0 > 7f6d03ddd000-7f6d03dde000 r--p 0000e000 08:02 9182983 > /usr/lib/libXi.so.6.1.0 > 7f6d03dde000-7f6d03ddf000 rw-p 0000f000 08:02 9182983 > /usr/lib/libXi.so.6.1.0 > 7f6d03ddf000-7f6d03df0000 r-xp 00000000 08:02 9182894 > /usr/lib/libXext.so.6.4.0 > 7f6d03df0000-7f6d03fef000 ---p 00011000 08:02 9182894 > /usr/lib/libXext.so.6.4.0 > 7f6d03fef000-7f6d03ff0000 r--p 00010000 08:02 9182894 > /usr/lib/libXext.so.6.4.0 > 7f6d03ff0000-7f6d03ff1000 rw-p 00011000 08:02 9182894 > /usr/lib/libXext.so.6.4.0 > 7f6d03ff1000-7f6d03ff4000 r-xp 00000000 08:02 24905211 > /lib/libuuid.so.1.3.0 > 7f6d03ff4000-7f6d041f4000 ---p 00003000 08:02 24905211 > /lib/libuuid.so.1.3.0 > 7f6d041f4000-7f6d041f5000 r--p 00003000 08:02 24905211 > /lib/libuuid.so.1.3.0 > 7f6d041f5000-7f6d041f6000 rw-p 00004000 08:02 24905211 > /lib/libuuid.so.1.3.0 > 7f6d041f6000-7f6d04240000 r-xp 00000000 08:02 9181100 > /usr/lib/libpulsecommon-0.9.21.so > 7f6d04240000-7f6d04440000 ---p 0004a000 08:02 9181100 > /usr/lib/libpulsecommon-0.9.21.so > 7f6d04440000-7f6d04441000 r--p 0004a000 08:02 9181100 > /usr/lib/libpulsecommon-0.9.21.so > 7f6d04441000-7f6d04442000 rw-p 0004b000 08:02 9181100 > /usr/lib/libpulsecommon-0.9.21.so > 7f6d04442000-7f6d0445d000 r-xp 00000000 08:02 9182820 > /usr/lib/libxcb.so.1.1.0 > 7f6d0445d000-7f6d0465d000 ---p 0001b000 08:02 9182820 > /usr/lib/libxcb.so.1.1.0 > 7f6d0465d000-7f6d0465e000 r--p 0001b000 08:02 9182820 > /usr/lib/libxcb.so.1.1.0 > 7f6d0465e000-7f6d0465f000 rw-p 0001c000 08:02 9182820 > /usr/lib/libxcb.so.1.1.0 > 7f6d0465f000-7f6d04662000 r-xp 00000000 08:02 9183333 > /usr/lib/libxcb-atom.so.1.0.0 > 7f6d04662000-7f6d04862000 ---p 00003000 08:02 9183333 > /usr/lib/libxcb-atom.so.1.0.0 > 7f6d04862000-7f6d04863000 r--p 00003000 08:02 9183333 > /usr/lib/libxcb-atom.so.1.0.0 > 7f6d04863000-7f6d04864000 rw-p 00004000 08:02 9183333 > /usr/lib/libxcb-atom.so.1.0.0 > 7f6d04864000-7f6d04869000 r-xp 00000000 08:02 9183539 > /usr/lib/libXtst.so.6.1.0 > 7f6d04869000-7f6d04a69000 ---p 00005000 08:02 9183539 > /usr/lib/libXtst.so.6.1.0 > 7f6d04a69000-7f6d04a6a000 r--p 00005000 08:02 9183539 > /usr/lib/libXtst.so.6.1.0Aborted > > -- > Joseph Sanger > Blueberry Eikaiwa > www.bbeikaiwa.com > > > ------------------------------------------------------------------------------ > Colocation vs. Managed Hosting > A question and answer guide to determining the best fit > for your organization - today and in the future. > http://p.sf.net/sfu/internap-sfd2d > _______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie ------------------------------------------------------------------------------ Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2011-03-21 15:31 |
From | Steven Yi |
Subject | Re: [Cs-dev] Crash when stopping Csound using C API |
HI Joe, Could you post the C code you're using when you stop Csound? Thanks, steven On Mon, Mar 21, 2011 at 9:47 AM, Joseph Sanger |
Date | 2011-03-22 11:55 |
From | john ffitch |
Subject | Re: [Cs-dev] Crash when stopping Csound using C API |
t is reporting a double free; so run with a testing version of malloc (efence, nemosys( or under valgrind to see where. It would also be nice to know a what date/version you took csound. There have been fixes in memory errors ==John ffitch ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2011-03-24 11:40 |
From | Joseph Sanger |
Subject | Re: [Cs-dev] Crash when stopping Csound using C API |
Dear John, Victor and Steven, Thank you all for your replies. I'm sorry I'm late responding, I've been overwhelmingly busy the last few days. I haven't had a chance to put much of your advice into practice yet, although thanks to an earlier suggestion from Michael Gogins I'm rewriting a lot of the Macros I'm using as UDOs, which will make the orchestra size a lot smaller, which might help me in the short term. I've commented below... On 22/03/11 20:55, john ffitch wrote: > t is reporting a double free; so run with a testing version of > malloc (efence, nemosys( or under valgrind to see where. It > would also be nice to know a what date/version you took csound. > There have been fixes in memory errors > ==John ffitch I'll need to spend some time with Google before I try these suggestions, having never used these tools before. I'm learning a lot... Here is the csound version reported when I run it from the command line: Csound version 5.13 beta (double samples) Mar 17 2011 > Hi Joseph, > > the easiest thing for us would be if you could try isolating the > problem and giving us an example > we can work with. > > Various frontends use the bus, so if there was a bug in it, we would > have noticed it already. But > you never know. > > Alternatively, you might want to use the "invalue/outvalue" system > instead of chn opcodes and see if > it works better. > > Victor I will try and put together a simple example, but it'll take me some time as I'm juggling quite a lot of things at the moment. Thanks for reassuring me about the software bus though. I'm not doing anything particularly exotic with it, so if no-one else has found a bug it's probably my fault. Regarding invalue/outvalue, I tried them before and had some difficulties getting them to work actually; but I gave up using them anyway as I'm also using channels for audio - which I don't think invalue/outvalue are capable of. > HI Joe, > > Could you post the C code you're using when you stop Csound? > > Thanks, > steven Here it is. It's basically copied from the Rory Walsh API guide. // Here's the relevant part of the function which starts csound: ud->result=csoundCompile(ud->csound,csargc,csargv); if(!ud->result) { ud->perf_status=1; ThreadID=csoundCreateThread(csThread,(void *)ud); PRINT_MSG_0("Csound started!"); return 0; } else { PRINT_MSG("Couldn't start csound. Returned %i.", ud->result); csoundReset(ud->csound); return -1; } // Here's the thread: uintptr_t csThread(void * Data) { struct userData * ud = (struct userData *) Data; if (!ud->result) { while ((csoundPerformKsmps(ud->csound)==0) && (ud->perf_status==1)) ; csoundReset(ud->csound); } ud->perf_status=0; return 1; } // Here's the bit which stops csound: int stopCsound(struct userData * ud) { if (ud->perf_status==0) { //PRINT_MSG_0("Csound not running!"); return 0; } ud->perf_status=0; sleep(1); PRINT_MSG_0("Csound finished."); return 0; } Thanks for your helpful replies. Yours, Joe -- Joseph Sanger Blueberry Eikaiwa www.bbeikaiwa.com ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |