Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractMethodError when logging Exception #16

Closed
chatty opened this issue Aug 24, 2015 · 11 comments
Closed

AbstractMethodError when logging Exception #16

chatty opened this issue Aug 24, 2015 · 11 comments

Comments

@chatty
Copy link
Collaborator

chatty commented Aug 24, 2015

There has been an AbstractMethodError when using Throwable.printStackTrace for some users for quite a while now. It is unclear as to how that can even happen, because a thrown exception (to my understanding) shouldn't be abstract. Because of this there is little information as to what causes the error, but it appears to be related to the GUI.

It appears to only happen on Java 8, although that may be because it's the current version and most people use it. It seems to happen on different OS (at least on Windows 7/8.1, Linux, OSX).

Exception java.lang.AbstractMethodError: java.lang.Throwable.printStackTrace(Ljava/io/PrintWriter;)V
    occured during logging of uncaught exception: java.lang.ArrayIndexOutOfBoundsException [Thread[AWT-EventQueue-0,6,main]]

Any suggestions or help would be appreciated.

@night
Copy link

night commented Sep 5, 2015

Since the error occurs outside of your code, it might just be because of differing runtime version versus compiled Java version. I'd guess this to be a Java bug, not really one of your own.

Obviously the "fix" to this problem would be to fix whatever array index is out of bounds, but without a stack trace I guess that's less than helpful.

@MeFisto94
Copy link

To me this sounds like "printStackTrace" would be an AbstractMethod (i.e. not implemented by the runtime). Maybe some openSource implementation on some linux distributions don't support it accidentally? Or did this also happen on Windows?

You can, however implement your own method for that by iterating. Throwable has some kind of stacktrace you have to iterate over. That would workaround that issue to at least track the error down.

@Azzurite
Copy link

Azzurite commented Jan 4, 2016

How do you build the application when creating releases? It's probably a mismatch between linked classes.

@tduva
Copy link
Contributor

tduva commented Jan 4, 2016

I build it in Netbeans by clicking on "Clean and Build".

@Azzurite
Copy link

Azzurite commented Jan 4, 2016

Could you please provide the ANT script you created?

@Azzurite
Copy link

Azzurite commented Jan 4, 2016

Also, it's probably a bad idea to catch Throwable in ErrorHandler.java.
If the AbstractMethodError would not be catched it would probably help debug the problem. Right now, when this error happens, the UI just hangs when it should actually properly crash.

@tduva
Copy link
Contributor

tduva commented Jan 5, 2016

I'm not sure how that would give me any more information about the error. The UncaughtExceptionHandler is already the last resort. It informs the user about an error that might require the program to close and logs it to the debug file. So it's not like an error goes unnoticed because of that.

Because e.printStackTrace() on the Exception failed with an AbstractMethodError (and I think NullPointerExceptions), I added the catch Throwable in an attempt to log any useful information about the original error, which is the same as in the first post:

10:50:44 Unhandled Exception:
Exception java.lang.AbstractMethodError: java.lang.Throwable.printStackTrace(Ljava/io/PrintWriter;)V
    occured during logging of uncaught exception: java.lang.ArrayIndexOutOfBoundsException [Thread[AWT-EventQueue-0,6,main]]

Before it was something like this over an over again, which also could freeze the GUI, because of course an Exception in the ErrorHandler is also caught again by the ErrorHandler:

15:48:39 Unhandled Exception:
java.lang.AbstractMethodError: java.lang.Throwable.getStackTrace()[Ljava/lang/StackTraceElement;
    at chatty.ErrorHandler.uncaughtException(ErrorHandler.java:30)
    at java.lang.ThreadGroup.uncaughtException(Unknown Source)
    at java.lang.ThreadGroup.uncaughtException(Unknown Source)
    at java.awt.EventDispatchThread.processException(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

15:48:39 Unhandled Exception:
java.lang.NullPointerException
    at chatty.ErrorHandler.uncaughtException(ErrorHandler.java:33)
    at java.lang.ThreadGroup.uncaughtException(Unknown Source)
    at java.lang.ThreadGroup.uncaughtException(Unknown Source)
    at java.awt.EventDispatchThread.processException(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

I tried all sorts of things to get some information out of the original Exception, but even toString() was abstract as far as I can remember.

I also tried to compile the latest beta with Java 8 instead of Java 7 as before (because it seemed to occur mainly on Java 8), but I still had the error occur for people. Of course I'm not getting the error, so it's even harder to test stuff.

@Azzurite
Copy link

Azzurite commented Jan 5, 2016

Again, it probably has something to do with the build you're doing, linking with a class that is fine on your machine but having a different versions on other machines. It could also be a problem in one of the libraries.
Could you please post your build script somewhere for me to look at?

@Azzurite
Copy link

Azzurite commented Jan 5, 2016

Another idea would be, when an error occurs during the custom exception logging (like it happens here) to throw the original exception (the e in void uncaughtException(Thread t, Throwable e)) and let the JVM itself log it to stderr. If the JVM itself crashes on logging this exception, this would probably mean that there's a bug in the JVM. If the JVM does not crash, there's probably a bug somewhere in your build process or used libraries.
The second case is more likely, so it would be nice if I could take a look at your build script.

@tduva
Copy link
Contributor

tduva commented May 8, 2016

Good iea, but it's not possible to throw an exception in the uncaughtException method. I would have to add a throws to the method, but that means it doesn't override the method of the UncaughtExceptionHandler anymore.

I didn't make a build script, the IDE does all the building for me.

@tduva
Copy link
Contributor

tduva commented May 7, 2020

I haven't encountered this for a while, it may have been resolved by newer Java versions.

@tduva tduva closed this as completed May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants