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

Allow user reported exceptions to not suspend all threads #84

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

snmaynard
Copy link

Suspending all threads for user reported exceptions in games can cause a noticeable lag while the report is being generated so I've added a flag to control that functionality.

@kstenerud
Copy link
Owner

Hmm this could get a little dangerous. Trying to walk the stack trace of a running thread is just asking for trouble. Also, it would no longer be a snapshot of exactly where each thread was in relation to each other at the time of the crash.

If it's just the user portion that's causing problems, maybe we can only suspend the threads while they are being traced and then turn them back on afterwards?

@snmaynard
Copy link
Author

I toyed with that but its a little tricky to allow the other sentries to still lock all the threads (which presumably they need to do in the event of a terminal crash?)

Its easy to do if all sentries can rely on the threadwalker to lock the threads, but im not sure that's appropriate? I could possibly check to see if the threads are already locked further down and lock them if the usersentry has left the threads running?

If you let me know what approach is best I can throw the code together.

@kstenerud
Copy link
Owner

They only need to lock down the threads to ensure that the threads are all in the exact state they were in at the time of the crash. Technically, the threads only need to remain locked while the stack trace is generated. Once that's been saved, they can be restarted again.

Probably the best way to tackle this would be to allow the sentries to lock the threads, as they do now. Then, in KSCrashReport.c, move the writeAllThreads and writeMemoryInfo stuff up so that it gets written earlier, then unlock the threads and continue with the rest of the report, since the rest of the stuff is not temporal.

So then the order would be: lock threads (in the sentry), in kscrashreport_writeStandardReport call writeReportInfo, writeAllThreads, writeError, writeMemoryInfo, writeAppStats, unlock threads, write the rest of the report components

@kstenerud
Copy link
Owner

Gimme a few days to finish another feature I'm working on. This sort of change requires a level of thread safety that's not in the lower core yet.

@kstenerud
Copy link
Owner

Basically a lot of things need to be changed from global allocation to stack allocation (or even heap, where possible).

@rapinto
Copy link

rapinto commented Dec 13, 2016

Hi, same issue for me. I have several custom errors (maybe 20 errors) fired in a short period time, and suspending all threads is visually noticable.
If I comment the : kscrashsentry_suspendThreadsand kscrashsentry_resumeThreads it removes the lag.

Any advices? Is it worth to wait for you to take a look at this?

@kstenerud
Copy link
Owner

I'm working on thread safety as we speak :)

@croustibapt
Copy link

Really good news! Many thanks man!

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.

None yet

5 participants