[Cs-dev] Csound 6 on Android crashing on finish
Date | 2013-06-11 12:09 |
From | Michael Gogins |
Subject | [Cs-dev] Csound 6 on Android crashing on finish |
Attachments | None None |
It is still a problem that the Csound6 app crashes whenever performance stops, whether at the normal end of the csd or because the user stops it.
I have localized the crash to when csound.Reset() is called in CsoundObj. Did anything change in the reset code?
It is also possible that CsoundObj or CsoundAppActivity is trying to do something with memory that csound.Reset() has deallocated, and that this problem was introduced by re-ordering calls in the Java code. I am investigating this.
Regards, Mike Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com |
Date | 2013-06-11 18:49 |
From | Steven Yi |
Subject | Re: [Cs-dev] Csound 6 on Android crashing on finish |
I'm able to reproduce the crash here. With the debugger, I'm seeing this error message: 06-11 13:46:52.704: D/CsoundObj(15541): resetting Csound instance 06-11 13:46:52.704: A/libc(15541): @@@ ABORTING: LIBC: ARGUMENT IS INVALID HEAP ADDRESS IN dlfree addr=0x7347b5a0 I'm rebuilding CsoundAndroid with NDK_DEBUG=1 to see about getting more information. On Tue, Jun 11, 2013 at 7:09 AM, Michael Gogins |
Date | 2013-06-11 19:14 |
From | Steven Yi |
Subject | Re: [Cs-dev] Csound 6 on Android crashing on finish |
I did a little bit of debugging; I don't have the root cause yet, but I think I know where abouts things are crashing. Hopefully Victor can help as I think it's related to the code changes for csoundReset and reset. What I did was modify some logging messages in Top/csound.c in csoundReset: if(csound->engineStatus & CS_STATE_COMP) { /* and reset */ csound->Message(csound, "resetting Csound instance\n"); csound->Message(csound, "resetting Csound instance\n"); reset(csound); csound->Message(csound, "resetting Csound instance done\n"); /* clear compiled flag */ csound->engineStatus |= ~(CS_STATE_COMP); } I get the first "two resetting Csound instance" messages, but do not get the "done" message. In commit 99e2380, on June 9th, the call to memReset and calls to pthread_spin_init were moved from reset() to csoundReset(). I assume that this may be the cause, but I don't know enough about the original change to take this further. Victor: could you give some guidance on this? Thanks! steven On Tue, Jun 11, 2013 at 1:49 PM, Steven Yi |
Date | 2013-06-11 19:24 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Csound 6 on Android crashing on finish |
Attachments | None None |
I'd be surprised if the changes you found are not the cause. Regards, Mike Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Tue, Jun 11, 2013 at 2:14 PM, Steven Yi <stevenyi@gmail.com> wrote: I did a little bit of debugging; I don't have the root cause yet, but |
Date | 2013-06-11 19:46 |
From | Steven Yi |
Subject | Re: [Cs-dev] Csound 6 on Android crashing on finish |
I just rebuilt on desktop and can reproduce the issue with Python: >>> import csnd6 >>> c = csnd6.Csound() virtual_keyboard real time MIDI plugin for Csound 0dBFS level = 32768.0 Csound version 6.00rc3 (double samples) Jun 11 2013 libsndfile-1.0.25 >>> c.Stop() >>> c.Cleanup() end of score. overall amps: 0.0 overall samples out of range: 0 0 errors in performance Elapsed time at end of performance: real: 223.137s, CPU: 0.002s -1 >>> c.Reset() Csound tidy up: Segmentation fault Also if I just do c.Stop(), c.Reset() (without Cleanup()), it also crashes. This should at least make it easier to debug. On Tue, Jun 11, 2013 at 2:24 PM, Michael Gogins |
Date | 2013-06-11 19:46 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Csound 6 on Android crashing on finish |
The first change I did was to make sure reset() was not called when csound started, which appears to me correct. The problem was just memReset() and spinlock initialisation that was failing on Linux, that was fixed with moving it out of reset(). If you can get a better backtrace, we might be able to see where this fails. Victor On 11 Jun 2013, at 19:14, Steven Yi wrote: > I did a little bit of debugging; I don't have the root cause yet, but > I think I know where abouts things are crashing. Hopefully Victor can > help as I think it's related to the code changes for csoundReset and > reset. What I did was modify some logging messages in Top/csound.c in > csoundReset: > > if(csound->engineStatus & CS_STATE_COMP) { > /* and reset */ > csound->Message(csound, "resetting Csound instance\n"); > csound->Message(csound, "resetting Csound instance\n"); > reset(csound); > csound->Message(csound, "resetting Csound instance done\n"); > /* clear compiled flag */ > csound->engineStatus |= ~(CS_STATE_COMP); > } > > I get the first "two resetting Csound instance" messages, but do not > get the "done" message. > > In commit 99e2380, on June 9th, the call to memReset and calls to > pthread_spin_init were moved from reset() to csoundReset(). I assume > that this may be the cause, but I don't know enough about the original > change to take this further. > > Victor: could you give some guidance on this? > > Thanks! > steven > > > On Tue, Jun 11, 2013 at 1:49 PM, Steven Yi |
Date | 2013-06-11 19:49 |
From | Steven Yi |
Subject | Re: [Cs-dev] Csound 6 on Android crashing on finish |
Hi Victor, With GDB running python, I got: >>> c.Stop() >>> c.Reset() Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000010028bb3 0x00000001011ed476 in mfree (csound=0x1008e7600, p=0x10028db50) at memalloc.c:149 149 nxt->prv = prv; (gdb) bt #0 0x00000001011ed476 in mfree (csound=0x1008e7600, p=0x10028db50) at memalloc.c:149 #1 0x00000001012045a5 in cs_cons_free (csound=0x1008e7600, head=0x10028db50) at csound_data_structures.c:70 #2 0x0000000101357bbe in free_opcode_table (csound=0x1008e7600) at /Users/stevenyi/work/csound/csound6/Top/csound.c:114 #3 0x000000010135685a in create_opcode_table (csound=0x1008e7600) at /Users/stevenyi/work/csound/csound6/Top/csound.c:127 #4 0x0000000101351240 in csoundReset (csound=0x1008e7600) at /Users/stevenyi/work/csound/csound6/Top/csound.c:2771 #5 0x000000010109ade9 in Csound::Reset (this=0x1002495f0) at csound.hpp:363 #6 0x0000000101048173 in _wrap_Csound_Reset (args=0x1003c4250) at /Users/stevenyi/work/csound/cs6make/interfaces/python_interfacePYTHON_wrap.cxx:25106 #7 0x000000010001d5a9 in PyEval_EvalFrameEx () #8 0x0000000100021869 in _PyEval_SliceIndex () #9 0x000000010001d63a in PyEval_EvalFrameEx () #10 0x000000010001b147 in PyEval_EvalCodeEx () #11 0x000000010001a9b3 in PyEval_EvalCode () #12 0x0000000100056c70 in PyParser_ASTFromFile () #13 0x0000000100056ae9 in PyRun_InteractiveOneFlags () #14 0x0000000100056578 in PyRun_InteractiveLoopFlags () #15 0x0000000100056414 in PyRun_AnyFileExFlags () #16 0x000000010007ae27 in Py_Main () #17 0x00007fff8dbdb7e1 in start () Current language: auto; currently minimal (gdb) On Tue, Jun 11, 2013 at 2:46 PM, Victor Lazzarini |
Date | 2013-06-11 19:58 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Csound 6 on Android crashing on finish |
OK thanks. See if my latest changes to GIT fix this (it does here on Python). Victor On 11 Jun 2013, at 19:49, Steven Yi wrote: > Hi Victor, > > With GDB running python, I got: > >>>> c.Stop() >>>> c.Reset() > > Program received signal EXC_BAD_ACCESS, Could not access memory. > Reason: KERN_INVALID_ADDRESS at address: 0x0000000010028bb3 > 0x00000001011ed476 in mfree (csound=0x1008e7600, p=0x10028db50) at > memalloc.c:149 > 149 nxt->prv = prv; > (gdb) bt > #0 0x00000001011ed476 in mfree (csound=0x1008e7600, p=0x10028db50) at > memalloc.c:149 > #1 0x00000001012045a5 in cs_cons_free (csound=0x1008e7600, > head=0x10028db50) at csound_data_structures.c:70 > #2 0x0000000101357bbe in free_opcode_table (csound=0x1008e7600) at > /Users/stevenyi/work/csound/csound6/Top/csound.c:114 > #3 0x000000010135685a in create_opcode_table (csound=0x1008e7600) at > /Users/stevenyi/work/csound/csound6/Top/csound.c:127 > #4 0x0000000101351240 in csoundReset (csound=0x1008e7600) at > /Users/stevenyi/work/csound/csound6/Top/csound.c:2771 > #5 0x000000010109ade9 in Csound::Reset (this=0x1002495f0) at csound.hpp:363 > #6 0x0000000101048173 in _wrap_Csound_Reset (args=0x1003c4250) at > /Users/stevenyi/work/csound/cs6make/interfaces/python_interfacePYTHON_wrap.cxx:25106 > #7 0x000000010001d5a9 in PyEval_EvalFrameEx () > #8 0x0000000100021869 in _PyEval_SliceIndex () > #9 0x000000010001d63a in PyEval_EvalFrameEx () > #10 0x000000010001b147 in PyEval_EvalCodeEx () > #11 0x000000010001a9b3 in PyEval_EvalCode () > #12 0x0000000100056c70 in PyParser_ASTFromFile () > #13 0x0000000100056ae9 in PyRun_InteractiveOneFlags () > #14 0x0000000100056578 in PyRun_InteractiveLoopFlags () > #15 0x0000000100056414 in PyRun_AnyFileExFlags () > #16 0x000000010007ae27 in Py_Main () > #17 0x00007fff8dbdb7e1 in start () > Current language: auto; currently minimal > (gdb) > > On Tue, Jun 11, 2013 at 2:46 PM, Victor Lazzarini > |
Date | 2013-06-11 20:00 |
From | Michael Gogins |
Subject | Re: [Cs-dev] Csound 6 on Android crashing on finish |
Attachments | None None |
Thanks for the prompt work. I'll check this first thing after dinner this evening. Regards, Mike
Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Tue, Jun 11, 2013 at 2:58 PM, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote: OK thanks. See if my latest changes to GIT fix this (it does here on Python). |
Date | 2013-06-11 20:27 |
From | Steven Yi |
Subject | Re: [Cs-dev] Csound 6 on Android crashing on finish |
I tested here and am not getting the same crash now. I think it is now fixed and working. I am however getting another crash with CsoundObj if I stop an example, then press back and stopCsound is called again. Hopefully should be an easy fix here. There is another issue though: Csound stutters pretty badly on the Nexus 4. From the Google I/O video, I seem to recall that for the N4, an SR of 48000 and buffer size of 240 is supposed to be used and that it is what is returned when querying the device. I suspect we may need to change a little of how CsoundObj works and have it do some automatic overriding of sr/ksr/ksmps to match the device's reported values. I'm going to look into CsoundObj crash, then move on the rest of things for getting an RC3 out. I suspect this issue has been here for N4 already, so we can look at it as a post-RC3 issue to fix. On Tue, Jun 11, 2013 at 3:00 PM, Michael Gogins |