I'm using Fabric to report crash for my app. I have received those report for a very long time and the number of crashes keep increasing.
Fatal Exception: java.lang.InternalError: Thread starting during runtime shutdown
at java.lang.Thread.nativeCreate(Thread.java)
at java.lang.Thread.start(Thread.java:730)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:941)
at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1151)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
There is also a list of 62 Threads attached with this report, I can post it here if you guys want.
I have no idea which part of code cause this or how to replicate the bug. So I hope you can guide me to find and solve this case.
The current thread is started too late, that is, when you receive an uncaught exception in the UncaughtExceptionHandler, a child thread is started to upload the error log. HttpClient is created when the error log is uploaded, but ThreadSafeClientConnManager was set to manage the connection when created.
By viewing the source code of ThreadSafeClientConnManager, it was found that ThreadSafeClientConnManager also opened child threads, which caused the problem of opening child threads in child threads, which would cause uncaughtException () in the thread after execution was completed Only when the thread is started, java.lang.InternalError: Thread starting during runtime shutdown will be thrown.
The solution to this problem is: Create HttpClient in advance, because HttpClient creation will also start the thread, avoid creation in uncaughtException (), thereby avoiding the problem of starting the thread in the thread.
Alternative solution: Remove UncaughtExceptionHandler from your code in case it tried to create a thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With