Java crashes


    Jun 21 2006 | 12:00 pm
    I can't find again the recent topic about java & threads, and i guess i'll need more explanations too... So, i have major crashes followed by a Java hot Spot VM (?!) crash log written on my machine. It appears after a few time i rewrite the name of my mxj external, and it seems because the thread is not dead, or the memory is still in use (got, sometime, in the same situation, a lot of free bad object blablabla...). What do i have to know about this ? What do i have to write in my code to make it safe ?
    Thanks in advance
    f.e
    ps: extract of the log :
    # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0041d1f3, pid=5416, tid=4920 # # Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode) # Problematic frame: # C [max.exe+0x1d1f3] #
    --------------- T H R E A D ---------------
    Current thread (0x088622b8): JavaThread "main" [_thread_in_native, id=4920]
    siginfo: ExceptionCode=0xc0000005, reading address 0x00000010
    Registers: EAX=0x00000000, EBX=0x00000000, ECX=0x00000018, EDX=0x00000000 ESP=0x0012d9f0, EBP=0x0012da2c, ESI=0x063ca030, EDI=0x088622b8 EIP=0x0041d1f3, EFLAGS=0x00010246
    Top of Stack: (sp=0x0012d9f0) 0x0012d9f0: 201dc758 08ede404 00000000 201dc758 0x0012da00: 08f1826f 08862378 0012da40 00000002 0x0012da10: 0012da10 00000000 0012da40 201e7358 0x0012da20: 00000000 201dc758 0012da3c 0012da60 0x0012da30: 08f12a7b 00000000 08f16430 00000002 0x0012da40: 104420d0 0012da44 201dab92 0012da6c 0x0012da50: 201e7358 00000000 201dabb8 0012da68 0x0012da60: 0012da8c 08f12a7b 00000002 104420d0
    Instructions: (pc=0x0041d1f3) 0x0041d1e3: 00 00 00 89 1d 58 60 53 00 b8 01 00 00 00 5b c3 0x0041d1f3: 8b 48 10 56 57 8b 3d b4 4c 53 00 3b cf 75 23 8b
    Stack: [0x00030000,0x00130000), sp=0x0012d9f0, free space=1014k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [max.exe+0x1d1f3] j com.cycling74.max.MaxObject.outletBang(I)Z+2 j fe.fadeX_3.loopX([Lcom/cycling74/max/Atom;)V+534 v ~StubRoutines::call_stub C 0x6d6f45a9 C 0x6d749317 C 0x6d6f447a C 0x6d6f98a1 C 0x08edbcd0
    Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j com.cycling74.max.MaxObject.doOutletBang(I)Z+0 j com.cycling74.max.MaxObject.outletBang(I)Z+2 j fe.fadeX_3.loopX([Lcom/cycling74/max/Atom;)V+534 v ~StubRoutines::call_stub
    -- f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|

    • Jun 21 2006 | 1:27 pm
      Moving this thread to the Java topic...
    • Jun 21 2006 | 2:42 pm
      Other questions related to this problem :
      Is it better to use Timer & TimerTask (which i do) classes or MaxClock class when it's only to delay an event (a few floats out an outlet) ?
      Topher, i'm reading your excellent & usefull overview of threading at the end of the Tutorial (i should have read this before, for sure) and i wonder : i'm using a java external to do quick buffer manipulation (lots of peek and poke) *while* recording / playing, and i plan to use *dozen* of this one in the same patch. So, do i have to take care of threads ? If yes, as i guess, do i have to use the Qelems style or the Java threads example below ?
      many many thanks
      f.e
      f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|
      f.e wrote: > I can't find again the recent topic about java & threads, and i guess > i'll need more explanations too... So, i have major crashes followed > by a Java hot Spot VM (?!) crash log written on my machine. It appears > after a few time i rewrite the name of my mxj external, and it seems > because the thread is not dead, or the memory is still in use (got, > sometime, in the same situation, a lot of free bad object > blablabla...). What do i have to know about this ? What do i have to > write in my code to make it safe ? > > Thanks in advance > > f.e > > ps: extract of the log : > > # > # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0041d1f3, pid=5416, > tid=4920 > # > # Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode) > # Problematic frame: > # C [max.exe+0x1d1f3] > # > > --------------- T H R E A D --------------- > > Current thread (0x088622b8): JavaThread "main" [_thread_in_native, > id=4920] > > siginfo: ExceptionCode=0xc0000005, reading address 0x00000010 > > Registers: > EAX=0x00000000, EBX=0x00000000, ECX=0x00000018, EDX=0x00000000 > ESP=0x0012d9f0, EBP=0x0012da2c, ESI=0x063ca030, EDI=0x088622b8 > EIP=0x0041d1f3, EFLAGS=0x00010246 > > Top of Stack: (sp=0x0012d9f0) > 0x0012d9f0: 201dc758 08ede404 00000000 201dc758 > 0x0012da00: 08f1826f 08862378 0012da40 00000002 > 0x0012da10: 0012da10 00000000 0012da40 201e7358 > 0x0012da20: 00000000 201dc758 0012da3c 0012da60 > 0x0012da30: 08f12a7b 00000000 08f16430 00000002 > 0x0012da40: 104420d0 0012da44 201dab92 0012da6c > 0x0012da50: 201e7358 00000000 201dabb8 0012da68 > 0x0012da60: 0012da8c 08f12a7b 00000002 104420d0 > > Instructions: (pc=0x0041d1f3) > 0x0041d1e3: 00 00 00 89 1d 58 60 53 00 b8 01 00 00 00 5b c3 > 0x0041d1f3: 8b 48 10 56 57 8b 3d b4 4c 53 00 3b cf 75 23 8b > > > Stack: [0x00030000,0x00130000), sp=0x0012d9f0, free space=1014k > Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, > C=native code) > C [max.exe+0x1d1f3] > j com.cycling74.max.MaxObject.outletBang(I)Z+2 > j fe.fadeX_3.loopX([Lcom/cycling74/max/Atom;)V+534 > v ~StubRoutines::call_stub > C 0x6d6f45a9 > C 0x6d749317 > C 0x6d6f447a > C 0x6d6f98a1 > C 0x08edbcd0 > > Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) > j com.cycling74.max.MaxObject.doOutletBang(I)Z+0 > j com.cycling74.max.MaxObject.outletBang(I)Z+2 > j fe.fadeX_3.loopX([Lcom/cycling74/max/Atom;)V+534 > v ~StubRoutines::call_stub >
    • Jun 21 2006 | 3:04 pm
      On 21 Jun 2006, at 15:42, f.e wrote:
      > i'm using a java external to do quick buffer manipulation (lots of > peek and poke) *while* recording / playing, and i plan to use > *dozen* of this one in the same patch. So, do i have to take care > of threads ?
      The short answer is that you *always* have to take care of threads, so I'd recommend looking for some tutorial articles on multithreading, thread-safety, synchronization and semaphores. It does sound as if your application is somewhat thready.
      -- N.
      nick rothwell -- composition, systems, performance -- http:// www.cassiel.com
    • Jun 21 2006 | 3:52 pm
      Yes. What i've understood is : there's two general threads. The main thread (aka low prirority thread) where everything is running when overdrive is off. Then, there's a High Priority thread (aka scheduler) where timing critical events are running (metro, midi...) while non-critical timining events (UI, messages...) stay in the main thread, only when overdrive is on. We can also create abritrary Java threads inside our external, to handle things in another thread than these two ones.
      The job of my external is not extremely computationnaly intensive, but it does crossfades & editing into a buffer~ just after being recorded, sends a few infos back to max network (a bang, a couple of floats for new loop points), and has to do this while audio is playing. I've also added a delayed event, using Timer / TimerTask classes, to output this bang and these floats.
      First, i had to turn overdrive off because of sudden audio interruptions while my external was filling the buffer~. I can deal with that, or do some tricks in the Performance options to make things better.
      But my real problem is unknown. Sometimes i don't have any, sometimes i got crashes for no reason i could identify. I must say my Eclipse IDE is always opened, and i'm continuously rewriting, saving and reloading my object.
      So will it be safer to create a special new thread for my external, and to dispose from it when it's erased ? to defer the buffer writing with Qelem ? or is it another problem ?
      best
      f.e
      f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|
      Nick Rothwell wrote: > > On 21 Jun 2006, at 15:42, f.e wrote: > >> i'm using a java external to do quick buffer manipulation (lots of >> peek and poke) *while* recording / playing, and i plan to use *dozen* >> of this one in the same patch. So, do i have to take care of threads ? > > The short answer is that you *always* have to take care of threads, so > I'd recommend looking for some tutorial articles on multithreading, > thread-safety, synchronization and semaphores. It does sound as if > your application is somewhat thready. > > -- N. > > > nick rothwell -- composition, systems, performance -- > http://www.cassiel.com > > > >
    • Jun 21 2006 | 4:22 pm
    • Jun 21 2006 | 4:27 pm
      Another clue : crash happens when i open a previous version of my object, or rewrite the name of the new version in an old one's box. Crash also when i, for example, use it without problem for a while, then, with it still there somewhere in a patch, open buf.Op class, for example. A load of "freeobject bad object" in the max console and pfuiiit (or pshiiiiit as french may say ;-) )
      f.e
      f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|
      Nick Rothwell wrote: > > On 21 Jun 2006, at 15:42, f.e wrote: > >> i'm using a java external to do quick buffer manipulation (lots of >> peek and poke) *while* recording / playing, and i plan to use *dozen* >> of this one in the same patch. So, do i have to take care of threads ? > > The short answer is that you *always* have to take care of threads, so > I'd recommend looking for some tutorial articles on multithreading, > thread-safety, synchronization and semaphores. It does sound as if > your application is somewhat thready. > > -- N. > > > nick rothwell -- composition, systems, performance -- > http://www.cassiel.com > > > >
    • Jun 22 2006 | 1:11 pm
      So, Topher's not around these days... :-{
      I really need to know where to put things in order for my java external not to interrupt audio playback when doing something. Is it the output to max (floats and bangs) which i have to put in OutletHigh or to defer ? Or is it the function which calculates a crossfades which i have to put in High Thread or to defer ? Or both ? Do i only have to change my performance settings ?
      Again, i'd really appreciate a comprehensive answer or advice.
      Again, thanks in advance
      best
      f.e
      f.e chanfrault | aka | personal computer music > >>>>>> http://www.personal-computer-music.com > >>>>>> |sublime music for a desperate people|
      Nick Rothwell wrote: > > On 21 Jun 2006, at 15:42, f.e wrote: > >> i'm using a java external to do quick buffer manipulation (lots of >> peek and poke) *while* recording / playing, and i plan to use *dozen* >> of this one in the same patch. So, do i have to take care of threads ? > > The short answer is that you *always* have to take care of threads, so > I'd recommend looking for some tutorial articles on multithreading, > thread-safety, synchronization and semaphores. It does sound as if > your application is somewhat thready. > > -- N. > > > nick rothwell -- composition, systems, performance -- > http://www.cassiel.com > > > >
    • Jun 22 2006 | 1:46 pm
      > I really need to know where to put things in order for my java > external not to interrupt audio playback when doing something.
      That's a rather generic request...
      I guess the obvious question is: is your Java code spending more time (overall) calculating than the time in which it has to generate the audio? If so, then there's no solution. (Your DSP usage figure is greater than 100%.)
      At the other end of the scale, if your Java code is doing very little, then generating signal vectors can be done in plenty of time before outputting them, and there's no problem.
      More likely is a situation is somewhere between the two: overall you can do your calculations for the signal vectors in less time than their duration, but there will be bursts of activity when you exceed the available time, so your solution is to buffer the stream. (This is why file readers and network streamers use buffering; every now and then they take a performance or latency hit, but overall they can keep up.)
      Your best way of achieving this buffering is to decouple the code which generates the data from the code which outputs it, and the best way of doing that is to use cooperating threads: one feeding the buffer, one consuming it.
      This is all systems programming 101, and doesn't specifically address your problem, but I don't have a clear enough idea of what you're trying to do.
      > Is it the output to max (floats and bangs) which i have to put in > OutletHigh or to defer ? Or is it the function which calculates a > crossfades which i have to put in High Thread or to defer ?
      Firstly, what happens if you use a naive approach the programming and don't bother with any threading? Where are the CPU bottlenecks? In any case, crossfade calculation sounds like it should be in the buffer-populating thread, since it is probably a peak consumer of CPU.
      -- N.
      nick rothwell -- composition, systems, performance -- http:// www.cassiel.com
    • Jun 22 2006 | 3:55 pm
    • Jun 26 2006 | 10:48 am
      Hey f.e.,
      Please don't delete your posts... if that's what you're doing. It's really great to follow a discussion through, even when the poor programmer involved is having a tough time! I, for one, have had similar Java crashes in the past, and they weren't thread-related, as my Java stuff was all in a single thread.
      It would be good to see where all this went.
      J.
    • Jun 30 2006 | 2:48 pm
      heh... cheeky.