Modify

Opened 15 years ago

Closed 13 years ago

#5288 closed defect (fixed)

[patch] multiple JOSM instances: Bogus crash recovery attempt

Reported by: bastiK Owned by: team
Priority: minor Milestone:
Component: Core Version: latest
Keywords: Cc:

Description (last modified by Don-vip)

  • have one JOSM session open, do something else and then open another instance of JOSM

=> JOSM thinks it crashed and tries to recover the file that is still open in the first instance.

Attachments (1)

5288.patch (7.5 KB ) - added by Don-vip 13 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 by Don-vip, 13 years ago

Description: modified (diff)
Resolution: fixed
Status: newclosed

This must have fixed fixed in the last 2 years as the problem does not occur with latest.

comment:2 by rickmastfan67, 13 years ago

Resolution: fixed
Status: closedreopened

This isn't fixed. I was just able to duplicate it in r5475 after waiting about 5 or so minutes before opening a 2nd instance of JOSM.

comment:3 by Don-vip, 13 years ago

Summary: multiple JOSM instances: Bogus crash recovery attempt[patch] multiple JOSM instances: Bogus crash recovery attempt

Here's a patch tested on Windows, can someone try on other systems ?

The idea is to associate to each saved layer the PID of the JOSM instance that created it. Then, the new instance checks if the PID is still a running JVM (these hsperfdata files are created by HotSpot since java 1.4 and disappear when the JVM dies, for a normal stop or a crash).

comment:4 by bastiK, 13 years ago

doesn't compile with java 6

comment:5 by Don-vip, 13 years ago

You're sure ? I'm compiling in Java 6 and didn't use any private API. What's your error message ?

comment:6 by bastiK, 13 years ago

    [javac] /home/te/prog/josm-hist/core/src/org/openstreetmap/josm/data/AutosaveTask.java:284: cannot find symbol
    [javac] symbol  : method listFiles(org.openstreetmap.josm.actions.ExtensionFileFilter)
    [javac] location: class java.io.File
    [javac]         File[] files = autosaveDir.listFiles(OsmImporter.FILE_FILTER);
    [javac]                                   ^

It expects java.io.FileFilter but gets javax.swing.filechooser.FileFilter.

comment:7 by Don-vip, 13 years ago

Oh, my fault, I forgot to send a file. I let our ExtensionFileFilter implement java.io.FileFilter too as they have in common the same acceptFile() method.

Last edited 13 years ago by Don-vip (previous) (diff)

comment:8 by Don-vip, 13 years ago

FYI I tried to use JMX to check at runtime that the PID references a running JOSM instance and not just a Java application but encountered a lot of difficulties:

  • there's a simple Attach API that allows to attach to a local JVM without any configuration for it, but it's only present in JDK, not in JRE
  • as this API is lightweight (7 files only), I tried to include it into JOSM, but in fact, the API depends on larger native libraries (at least attach.dll on Windows) so I forgot it
  • I didn't find how to attach a local JVM without using this API

So I thought of this hsperfdata method. I only checks for file presence as I don't know if we can really "use" it (it seems to be a sort of memory mapping file used for jvmstat but the file is not readable, even File.exists() fails, and it's not documented)

If you have alternative ideas I'm listening :)

by Don-vip, 13 years ago

Attachment: 5288.patch added

comment:9 by bastiK, 13 years ago

Works on Ubuntu Linux. I'd say it is a difficult problem and your approach solves it. If anyone has a better idea, we can still improve it.

My only concern is, when the JVM crashes big time, it might leave those temporary files behind. This is indeed the case, when I send a KILL signal to the java process. After starting a new instance of JOSM, it is cleaned up however (the old hsperfdata file is gone, a new one created). So all in all it seems to work.

in reply to:  9 ; comment:10 by Don-vip, 13 years ago

Replying to bastiK:

My only concern is, when the JVM crashes big time, it might leave those temporary files behind. This is indeed the case, when I send a KILL signal to the java process. After starting a new instance of JOSM, it is cleaned up however (the old hsperfdata file is gone, a new one created). So all in all it seems to work.

OK we need then to do this test on more systems to be sure :)

in reply to:  10 ; comment:11 by skyper, 13 years ago

Replying to Don-vip:

Replying to bastiK:

My only concern is, when the JVM crashes big time, it might leave those temporary files behind. This is indeed the case, when I send a KILL signal to the java process. After starting a new instance of JOSM, it is cleaned up however (the old hsperfdata file is gone, a new one created). So all in all it seems to work.

OK we need then to do this test on more systems to be sure :)

Is it possible to make a built .jar available ? Thanks.

in reply to:  11 comment:12 by Don-vip, 13 years ago

Replying to skyper:

Is it possible to make a built .jar available ? Thanks.

Sure, here it is: http://www.sendspace.com/file/o97zad

comment:13 by stoecker, 13 years ago

Status of this?

comment:14 by skyper, 13 years ago

Did not get to test much (only different Linux i386 and amd64) but so far it always worked without problems where latest did show this bug.

comment:15 by bastiK, 13 years ago

I've tested the patch on Windows XP and it works well. After killing the process with taskkill /pid ... /f, the file in the hsperfdata_user folder vanished (this is good).

So in my opinion there is no reason to hold back this patch any longer.

comment:16 by Don-vip, 13 years ago

Resolution: fixed
Status: reopenedclosed

In 5566/josm:

fix #5288 - multiple JOSM instances: Bogus crash recovery attempt

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.