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 )
- 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)
Change History (17)
comment:1 by , 13 years ago
| Description: | modified (diff) |
|---|---|
| Resolution: | → fixed |
| Status: | new → closed |
comment:2 by , 13 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
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 , 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:5 by , 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 , 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 , 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.
comment:8 by , 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 , 13 years ago
| Attachment: | 5288.patch added |
|---|
follow-up: 10 comment:9 by , 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.
follow-up: 11 comment:10 by , 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 :)
follow-up: 12 comment:11 by , 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.
comment:12 by , 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:14 by , 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 , 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.



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