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

added flush as Unhandled exception will not be directed to NSLog otherwise #267

Merged
merged 1 commit into from
Feb 12, 2018

Conversation

dkimitsa
Copy link
Contributor

No description provided.

@dkimitsa
Copy link
Contributor Author

it is all about silent crashes https://dkimitsa.github.io/2018/02/12/investigating-silent-crash/

@Tom-Ski Tom-Ski merged commit 7904443 into MobiVM:master Feb 12, 2018
@intrigus
Copy link
Contributor

I'm not sure why this is a fix.
Doesn't this only fix the symptoms and not the cause?
The cause being that system.err should flush on each and every print/write/append/whatever call?

Please correct me if I'm wrong :)

@dkimitsa
Copy link
Contributor Author

@intrigus hi :)
please check long read link in the comment above )

@intrigus
Copy link
Contributor

@dkimitsa I re-read your post, but I still think that the better solution would be to flush here:

public void printStackTrace(PrintStream err) {

and here:
public void printStackTrace(PrintWriter err) {

instead of flushing in the uncaughtExceptionHandler.

OpenJDK does it the same way by printlning the information:
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/Throwable.java#524

@dkimitsa
Copy link
Contributor Author

@intrigus flushing in Throwable. printStackTrace is not a good idea as these methods are public ones and available for usage widely in user code. Flushing there will be unexpected behavior.

Open JDK doesn't do it same way. It is just uses println. println doesn't mean it will flush.
Flush in println is specific implementation of FoundationLogPrintStream

Flush in uncaughtExceptionHandler is good idea as it is last resort of application running code. And if flush is not happened any other place it is good place to do it before crashing

@dkimitsa dkimitsa deleted the fix_silent_output_on_uncaught branch May 23, 2018 08:11
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

Successfully merging this pull request may close these issues.

3 participants