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

NullPointerException in onClosed for Threaded Shell #94

Open
JesperLR opened this issue Aug 12, 2020 · 2 comments
Open

NullPointerException in onClosed for Threaded Shell #94

JesperLR opened this issue Aug 12, 2020 · 2 comments

Comments

@JesperLR
Copy link

Hi

We're experiencing a crash, coming from Shell object, that happens sporadically, but on many devices (+100 devices).
The crash is seen with the newest version of the lib, i.e. "eu.chainfire:libsuperuser:1.1.0.202004101746"

The stacktrace is as following:

Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'boolean java.lang.Thread.isAlive()' on a null object reference
eu.chainfire.libsuperuser.Shell$Threaded.onClosed (Shell.java:2884)
eu.chainfire.libsuperuser.Shell$Interactive.runNextCommand (Shell.java:1876)
eu.chainfire.libsuperuser.Shell$Interactive.runNextCommand (Shell.java:1726)
eu.chainfire.libsuperuser.Shell$Interactive.access$3700 (Shell.java:1526)
eu.chainfire.libsuperuser.Shell$Interactive$6.onStreamClosed (Shell.java:2119)
eu.chainfire.libsuperuser.StreamGobbler.run (StreamGobbler.java:169)

Looking at Shell.java:2884 it's obvious that it will produce a nullPointer (possibly in multiple following lines as well) if the handlerThread field variable is null.

Unfortunately I have not been able to reproduce the crash myself. I have also not been able to logically walk through the Shell code to understand how onClosed may be called while handlerThread is still null, or how it could somehow become a null object before the final statement is reached in onClosed. My best guess would therefore be a couple of simple null checks, which I assume would be safe in terms of quitting the thread, as it presumably would not exist or already have been GC in that case.

Any help or possible fix would be greatly appreciated, thanks! :)

@Kilo-411
Copy link

Kilo-411 commented Dec 4, 2020

what is your kernal?

@JesperLR
Copy link
Author

JesperLR commented Dec 6, 2020

Hi, I'm not sure how the kernel of the devices that experience this issue are relevant - can you elaborate on that?

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

No branches or pull requests

2 participants