2

While doing some homework that works with some swing gui components, my program started crashing seemingly at random. That is, it starts, runs for a short time, and then crashes. I don't get any errors in the console, it's just a straight up crash.

I don't doubt that it is something I wrote, and I'm more than happy to show code if anyone wants to look at it, but is there anything that I can do myself to track down what might be the cause of my crashes?

Some other information that might be useful:

  • I'm using eclipse, and the debugger doesn't seem to do anything that helps me with this (program still crashes).
  • I didn't notice any issues like this until I started to add event handling.
  • I'm using Windows 10.
  • Occasionally, nothing is drawn in the window I create. Exiting and then running the program again will cause it to work.
mKorbel
  • 109,525
  • 20
  • 134
  • 319
Jebbs
  • 58
  • 7
  • 2
    You should add logging statements to your application. Then you will have some info about how far your program went. – Seelenvirtuose May 13 '15 at 06:30
  • Not hitting a `System.exit` anywhere... – MadProgrammer May 13 '15 at 06:32
  • its not reacting anymore or really crashing? in the second case you should have a stackTrace. in the first case it seems like a deadlock between threads which is really annoying to find/debug – Manuel Jain May 13 '15 at 06:32
  • @MadProgrammer - There are no System.exit()'s anywhere. – Jebbs May 13 '15 at 06:35
  • @ManuelJain - It is a genuine crash. How can I view the stack trace? I'm not sure how to do that in eclipse. – Jebbs May 13 '15 at 06:36
  • It should all be in the console window. – laune May 13 '15 at 06:37
  • Nothing is in the console when it crashes aside from whatever I had sent to System.out while the program was running. – Jebbs May 13 '15 at 06:42
  • 1
    The term "crash" is not specific enough. Adding "genuine" doesn't help make it more specific. There are a number of behaviors that could be called a "crash". Please let us know what the exact behavior is. – ajb May 13 '15 at 06:42
  • I get a notification from Windows that my binary has stopped working. The information in the notification is "Java(TM) Platform SE binary has stopped working." Then it closes the program. – Jebbs May 13 '15 at 06:46
  • Then it must have reached a normal program end. It seems that we ought to see your code, at least as much as is necessary to reproduce the problem. – laune May 13 '15 at 07:08
  • @laune In my experience, programs that reach a "normal end" don't cause messages that say "your binary has stopped working". This appears to be a bug in the Java platform, or an OS or even a hardware problem. – ajb May 14 '15 at 04:57
  • @ajb Much here is poorly written, this message - "has stopped working" may have at least three significantly different meanings. And: "...it closes the program..." is another imprecisely formulated phrase. It - who is it? Close a program? – laune May 14 '15 at 10:36
  • @laune I'm not sure if you mean three significantly different meanings in normal English speech or writing. However, on Windows, the box that shows up and says that some program "has stopped working" (the popup contains those exact words) shows up only in the case of an unrecoverable error, such as an invalid opcode or access to an invalid address. This box will not show up when the program terminates normally, even though it's possible that a human might use the phrase "has stopped working" when a program stops normally. – ajb May 15 '15 at 06:10
  • @ajb Thanks for the clarification. I just wonder why they didn't use "stopped due to unrecoverable error" or s.th. to that effect... – laune May 15 '15 at 12:15

1 Answers1

2

Some possible heuristics:

  • Crashes that occur seemingly at random suggest incorrect synchronization; look for event dispatch thread violation using one of the approaches cited here.

  • Verify that all exception handlers produce diagnostic output; run from the command line to ensure that diagnostic output has not been inadvertently redirected.

  • Try running under the aegis of a different debugger, e.g. NetBeans.

  • Try running under the aegis of a profiler.

  • Try a different version of the JDK/JRE.

  • Try a different host OS.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • I'm going to pick this as the answer as it turned out to be my own computer that is most likely causing the issues. Building my application on a different computer (ie, not Windows 10) seems to have solved the random crashes and it wasn't anything to do with my actual code (as far as I can tell). – Jebbs May 13 '15 at 17:01
  • Ouch! Also check for spurious entries in the system's `java.endorsed.dirs`, `java.ext.dirs` and `java.library.path`. – trashgod May 13 '15 at 17:04