Android UI Crash due to kernel error - android

When I return error from linux system calls like create/open etc. in order to fail such operations from my App, complete Android UI crashes. When I investigated more I realized that root cause is the system_server crashing because of my errors from system call.
I tried using errors like EACCESS, EBADF etc but each of these seems to be considered as a fatal exception by Android!
Any idea on non-fatal error values which I can use such that it does not cause Android UI to crash?

Related

Unexpected failure during lint analysis since `androidx-livedata` update 2.3.0

While running lint a strange error occurred. This appears to happen after a androidx.lifecycle update from 2.2.0 to 2.3.0:
../../src/main/java/my/project/MyService.kt: Unexpected failure during lint analysis of MyService.kt
(this is a bug in lint or one of the libraries it depends on)
Message: org.jetbrains.uast.UastErrorType cannot be cast to com.intellij.psi.PsiClassType
The crash seems to involve the detector androidx.lifecycle.lint.NonNullableMutableLiveDataDetector.
You can try disabling it with something like this:
android {
lintOptions {
disable "NullSafeMutableLiveData"
}
}
Stack: ClassCastException:NonNullableMutableLiveDataDetector.visitMethodCall(NonNullableMutableLiveDataDetector.kt:103)
←UElementVisitor$DelegatingPsiVisitor.visitMethodCallExpression(UElementVisitor.kt:1079)
←UElementVisitor$DelegatingPsiVisitor.visitCallExpression(UElementVisitor.kt:1059)
←UCallExpression$DefaultImpls.accept(UCallExpression.kt:85)
←UCallExpressionEx$DefaultImpls.accept(UCallExpression.kt:-1)
←KotlinUSimpleReferenceExpression$KotlinAccessorCallExpression.accept(KotlinUSimpleReferenceExpression.kt:129)
←KotlinUSimpleReferenceExpression.visitAccessorCalls(KotlinUSimpleReferenceExpression.kt:116)
←KotlinUSimpleReferenceExpression.accept(KotlinUSimpleReferenceExpression.kt:83)
You can set environment variable LINT_PRINT_STACKTRACE=true to dump a full stacktrace to stdout.
This issue type represents a problem running lint itself. Examples include failure to find bytecode for source files (which means certain detectors could not be run), parsing errors in lint configuration files, etc.
These errors are not errors in your own code, but they are shown to make it clear that some checks were not completed.
To suppress this error, use the issue id "LintError" as explained in the Suppressing Warnings and Errors section.
When I disable NullSafeMutableLiveData - as suggested - the error doesn't occur anymore, great! But I wonder where this issue comes from and if there's a better solution than simply ignoring that specific check completely. Is it a bug in the androidx.lifecycle dependency I could report, or is it possible to somehow conflict with an error in my project I could fix? (if so, any advice finding out where?)
Note: this only happened when lint was run on Bitrise, I didn't encounter this when running lint in Android Studio. Not sure if this is somehow related though.

How can I black-box a library in the android debugger

I'm using khttp to perform HTTP requests in my Android app, but every time I start adding breakpoints to my app in Android Studio 3.1, I'm getting this really annoying Illegal State Exception, at which point I them need to restart Android Studio. Here's an example of the exception thrown:
E/AndroidRuntime: FATAL EXCEPTION: Thread-4
Process: com.sbrl.peppermint, PID: 10777
java.lang.IllegalStateException: Cannot access request header fields after connection is set
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getRequestProperties(HttpURLConnectionImpl.java:232)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getRequestProperties(DelegatingHttpsURLConnection.java:182)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getRequestProperties(Unknown Source:0)
at com.android.tools.profiler.support.network.httpurl.TrackedHttpURLConnection.getRequestProperties(TrackedHttpURLConnection.java:204)
at com.android.tools.profiler.support.network.httpurl.TrackedHttpURLConnection.trackPreConnect(TrackedHttpURLConnection.java:63)
at com.android.tools.profiler.support.network.httpurl.TrackedHttpURLConnection.connect(TrackedHttpURLConnection.java:126)
at com.android.tools.profiler.support.network.httpurl.HttpsURLConnection$.connect(HttpsURLConnection$.java:366)
at khttp.responses.GenericResponse.openRedirectingConnection$khttp(GenericResponse.kt:125)
at khttp.responses.GenericResponse.getConnection(GenericResponse.kt:163)
at khttp.responses.GenericResponse.getRaw(GenericResponse.kt:207)
at khttp.responses.GenericResponse.getContent(GenericResponse.kt:216)
at khttp.responses.GenericResponse.init$khttp(GenericResponse.kt:377)
at khttp.KHttp.request(KHttp.kt:61)
at khttp.KHttp.request$default(KHttp.kt:59)
I know that this question explains why this is happening, but my question is this:
How can I black-box the khttp library (similar to the way that Chrome allows you to black-box a JS source file), such that the Android debugger does not inspect it - throwing this exception?

Every runtime error reported as SIGSEGV error in android studio

I have linked some c++ codes to android studio project and it works with no problem, but every time I encounter with a runtime error in java code, android studio won't tell me the problem precisely and reports only this error in debugger:
Signal = SIGSEGV (signal SIGSEGV: invalid address (fault address: 0xc))
What is the problem?
This primarily occurs due to one of the 2 reasons :
1) Invalid memory reference.
2) Eating up too much memory.
Now, debugging this issue can be a bit intimidating.
So start finding out points where your code may be doing INVALID MEMORY ACCESS causing SIGSEGV error or points where your code is starting too many threads.
And You have to find out if this issue is regularly occuring or 1 in 5(or so) times.
Because I encountered the problem in one project and that occured 1 in 5-6 times.

Error while trying to apportable iOS app to Android

I have been trying to port my first iOS app to Android with apportable.
I have solved alot of warnings and errors but cannot get rid of this last one.
The App I made is a fitness application for jogging so it uses CoreLocation.
Everything looks good when I run apportable now except this last error:
Build/android-armeabi-debug/com.apptonix.easyrunner/testTabbedWithCore/libtestTabbedWithCore.a(DetailViewController.m.o):/Users/peterbodlund/Documents/xcodeprojects/Training/inlamning5/testTabbedWithCore/testTabbedWithCore/DetailViewController.m:function L_OBJC_CLASSLIST_REFERENCES_$_114: error: undefined reference to 'OBJC_CLASS_$_MKPinAnnotationView'
scons: * [Build/android-armeabi-debug/EasyRunner/apk/lib/armeabi/libverde.so] Error 1
scons: building terminated because of errors.
Exception AttributeError: "'NoneType' object has no attribute 'pack'" in > ignored
Usually this is an indicator that there were link errors. Check your output higher up and look for missing symbol errors.
The build log is confusing because the build is parallel by default.
Add the option -j1 to cause the build to stop immediately after the first error.

What causes signal 'SIGILL'?

I'm porting some C++ code to Android using NDK and GCC. The code basically runs. At one point, when debugging in Eclipse, the call
Dabbler::Android::Factory* pFactory = new Dabbler::Android::Factory;
causes this error:
Thread [1] (Suspended: Signal 'SIGILL' received. Description: Illegal instruction.)
1 <symbol is not available> 0x812feb44
What does that mean? Has the compiler generated illegal code for some reason? I have a breakpoint in the constructor (which does nothing), and it's not hit. I have already done a full rebuild.
What could I be doing wrong to cause this problem?
Make sure that all functions with non-void return type have a return statement.
While some compilers automatically provide a default return value, others will send a SIGILL or SIGTRAP at runtime when trying to leave a function without a return value.
It means the CPU attempted to execute an instruction it didn't understand. This could be caused by corruption I guess, or maybe it's been compiled for the wrong architecture (in which case I would have thought the O/S would refuse to run the executable). Not entirely sure what the root issue is.
It could be some un-initialized function pointer, in particular if you have corrupted memory (then the bogus vtable of C++ bad pointers to invalid objects might give that).
BTW gdb watchpoints & tracepoints, and also valgrind might be useful (if available) to debug such issues. Or some address sanitizer.
LeetCode's online compiler and dev environment generates SIGILL errors for mistakes that do not generate the same error in my desktop IDE.
For example, array access with an out-of-bounds index:
["foo", "bar"][2]
LeetCode's compiler shows only the error:
Runtime Error
process exited with signal SIGILL
in a local Xcode playground this same code instead results in the error:
error: Execution was interrupted, reason: EXC_BREAKPOINT (code=1, subcode=0x18f2ea5d8).
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.
Only in a full Xcode project compilation and run does it report the actual error:
Thread 1: Fatal error: Index out of range

Categories

Resources