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

Throwables#lazyStackTrace throws UnsupportedOperationException on AIX 5.3 #2887

Closed
kyle-cackett opened this issue Jul 28, 2017 · 5 comments
Closed
Labels

Comments

@kyle-cackett
Copy link

The mechanism which detects whether to fallback on the non-lazy stack trace implementation seems to be broken on AIX 5.3 with IBMs JDK jdk-6.0.0.645-aix-powerpc. When iterating through the list returned by the method on such a system I get the following exception + trace

Caused by: java.lang.UnsupportedOperationException: You cannot access stack trace depth this way in this implementation
at sun.misc.SharedSecrets$1.getStackTraceDepth(SharedSecrets.java:172)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.google.common.base.Throwables.invokeAccessibleNonThrowingMethod(Throwables.java:292)
at com.google.common.base.Throwables.access$200(Throwables.java:48)
at com.google.common.base.Throwables$1.size(Throwables.java:284)
at java.util.AbstractList$SimpleListIterator.hasNext(AbstractList.java:51)
at com.google.common.collect.Iterators$PeekingImpl.hasNext(Iterators.java:1171)
at com.delphix.logger.Logger.getLogger(Logger.java:96)
at com.delphix.session.impl.common.SessionManager.(SessionManager.java:23)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:199)
... 21 more

Explicitly using new Throwable().getStackTrace resolved the problem.

@cpovirk
Copy link
Member

cpovirk commented Aug 10, 2017

Thanks, and sorry for the slow response. It's unfortunate that IBM would define this method only to make it not work, but I assume they have their reasons. If you're interested in adding catch (UnsupportedOperationException e) and an appropriate fallback, we could take a pull request.

@fdesu
Copy link
Contributor

fdesu commented Sep 21, 2017

@cpovirk
I'm interested in this one, so if no one minds, I want to make an implementation for a fallback, however, should we care only for UnsupportedOperationException or it is worth to catch something generic e.g. RuntimeException? (hence I'm not a fan of such an idea)

@cpovirk
Copy link
Member

cpovirk commented Sep 21, 2017

Thanks! I would probably lean toward UnsupportedOperationException. That way, if we accidentally break our implementation, we're likely to still see the resulting exception, rather than silently catch it.

@kluever kluever added package=base type=defect Bug, not working as expected labels Sep 21, 2017
@fdesu
Copy link
Contributor

fdesu commented Sep 21, 2017

@cpovirk
Agree, will do it then and create a PR soon. Thanks!

fdesu added a commit to fdesu/guava that referenced this issue Sep 22, 2017
Fix addresses a problem occurred on AIX 5.3 with IBMs JDK.
To ensure that we can call underlying method to get
a stack size, Throwables#getSizeMethod, first a smoke test
performed with dummy exception. Once method executed
with success, it is safe to return it for further usage.

Issue: google#2887
fdesu added a commit to fdesu/guava that referenced this issue Sep 22, 2017
Fix addresses a problem occurred on IBM JDK 6. To ensure
that we can call underlying method, Throwables#getSizeMethod,
to get  stack size, first a smoke test  with dummy exception.
Once method executed with success, it is safe to return it for
further usage.

Issue: google#2887
fdesu added a commit to fdesu/guava that referenced this issue Sep 22, 2017
Fix addresses a problem occurred on IBM JDK 6. To ensure
that we can call underlying method, Throwables#getSizeMethod,
to get  stack size, first a smoke test  with dummy exception.
Once method executed with success, it is safe to return it for
further usage.

Issue: google#2887
@ronshapiro
Copy link
Contributor

@cpovirk can this be closed? Looks like the PR proposed for this issue was also closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants