Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 Return report id from user reports by naftaly · Pull Request #709 · kstenerud/KSCrash · GitHub
Nothing Special   »   [go: up one dir, main page]

Skip to content

Conversation

naftaly
Copy link
Collaborator
@naftaly naftaly commented Sep 14, 2025

Summary

This PR enhances the user report functionality by returning the report ID when creating user reports, allowing
callers to track and reference specific reports.

Changes Made

API Updates

  • C API: Modified kscrash_reportUserException() to return int64_t report ID instead of void
  • Objective-C API: Updated
    reportUserException:reason:language:lineOfCode:stackTrace:logAllThreads:terminateProgram: to return int64_t
    report ID
  • Internal APIs: Updated kscm_reportUserException() in the user monitor to return report ID

Implementation Details

  • Added kscrs_getNextCrashReportId() function to get the next report ID without incrementing the counter
  • Modified report generation flow to capture and return the report ID before writing the report
  • Returns 0 if the user monitor is not installed or if immediate exit is required

Possibly Breaking Changes

This is a breaking change for existing callers of the user exception reporting APIs, as the return type has
changed from void to int64_t.

Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the user exception reporting APIs to return report IDs, enabling callers to track and reference specific crash reports. The change affects both the C and Objective-C APIs by modifying return types from void to int64_t.

Key Changes:

  • Modified C API kscrash_reportUserException() to return int64_t report ID instead of void
  • Updated Objective-C API reportUserException:... method to return int64_t report ID
  • Added infrastructure to capture report IDs before generating reports

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Sources/KSCrashRecording/include/KSCrashC.h Updated C API function signature and documentation to return report ID
Sources/KSCrashRecording/include/KSCrash.h Updated Objective-C API method signature and documentation to return report ID
Sources/KSCrashRecording/Monitors/KSCrashMonitor_User.h Updated internal monitor API signature to return report ID
Sources/KSCrashRecording/Monitors/KSCrashMonitor_User.c Implemented report ID capture and return logic in user monitor
Sources/KSCrashRecording/KSCrashReportStoreC.c Added utility function to get next report ID without incrementing
Sources/KSCrashRecording/KSCrashReportStoreC+Private.h Added declaration for new report ID utility function
Sources/KSCrashRecording/KSCrashC.c Updated C API implementation to capture and return report ID
Sources/KSCrashRecording/KSCrash.m Updated Objective-C API implementation to capture and return report ID
Comments suppressed due to low confidence (1)

Sources/KSCrashRecording/include/KSCrash.h:161

  • This is a breaking change to the public Objective-C API. The method signature change from void to int64_t return type will break all existing call sites and change the method's Swift interface from returning Void to returning Int64.
- (int64_t)reportUserException:(NSString *)name
                        reason:(nullable NSString *)reason
                      language:(nullable NSString *)language
                    lineOfCode:(nullable NSString *)lineOfCode
                    stackTrace:(nullable NSArray *)stackTrace
                 logAllThreads:(BOOL)logAllThreads
              terminateProgram:(BOOL)terminateProgram;

Comment on lines +128 to +129
int64_t kscrash_reportUserException(const char *name, const char *reason, const char *language, const char *lineOfCode,
const char *stackTrace, bool 10BC0 logAllThreads, bool terminateProgram);
Copy link
Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change to the public C API. The function signature change from void to int64_t return type will break all existing call sites that don't expect a return value.

Copilot generated this review using guidance from repository custom instructions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The machine is absolutely right

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I even put it in the summary :)

Comment on lines -153 to +161
- (void)reportUserException:(NSString *)name
reason:(nullable NSString *)reason
language:(nullable NSString *)language
lineOfCode:(nullable NSString *)lineOfCode
stackTrace:(nullable NSArray *)stackTrace
logAllThreads:(BOOL)logAllThreads
terminateProgram:(BOOL)terminateProgram;
- (int64_t)reportUserException:(NSString *)name
reason:(nullable NSString *)reason
language:(nullable NSString *)language
lineOfCode:(nullable NSString *)lineOfCode
stackTrace:(nullable NSArray *)stackTrace
logAllThreads:(BOOL)logAllThreads
terminateProgram:(BOOL)terminateProgram;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change as well

*
* @return The report ID of the next report.
*/
int64_t kscrs_getNextCrashReportId(void);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of that, won't we get a TOCTOU race?

if (!g_isEnabled) {
KSLOG_WARN("User-reported exception monitor is not installed. Exception has not been recorded.");
return;
return -1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 is not very Swift-friendly. What else could we come up with that would bridge nicely to Swift?

@kstenerud
Copy link
Owner
kstenerud commented Sep 15, 2025

Don't we already get the report ID from KSCrashDidWriteReportCallback?

If they need to distinguish from other reports in the callback:

The entire report write and callback process is single-threaded (and always will be), so you could do a wrapper function like this:

  • Get the current thread ID (mach_thread_self() or any of the higher APIs that give you a comparable thread identifier)
  • Write the thread ID to thread-local storage
  • Call reportUserException
  • In your KSCrashDidWriteReportCallback, call mach_thread_self() again
  • If it matches what you put in thread-local storage, the report ID in this callback is the one you want.
  • Write this re 8000 port ID to thread-local storage
  • Once everything unwinds, fetch the report ID from thread-local storage and return it.

Then no matter how or when we generate a report ID in future, you'll always get the correct one.

@naftaly
Copy link
Collaborator Author
naftaly commented Sep 15, 2025

Don't we already get the report ID from KSCrashDidWriteReportCallback?

If they need to distinguish from other reports in the callback:

The entire report write and callback process is single-threaded (and always will be), so you could do a wrapper function like this:

  • Get the current thread ID (mach_thread_self() or any of the higher APIs that give you a comparable thread identifier)
  • Write the thread ID to thread-local storage
  • Call reportUserException
  • In your KSCrashDidWriteReportCallback, call mach_thread_self() again
  • If it matches what you put in thread-local storage, the report ID in this callback is the one you want.
  • Write this report ID to thread-local storage
  • Once everything unwinds, fetch the report ID from thread-local storage and return it.

Then no matter how or when we generate a report ID in future, you'll always get the correct one.

That's sort of how I'm doing it now, but it's really cumbersome. I Kindof expected this to not pass the smell test, but I find it would be a great improvement. I'll just continue with how I'm already doing it instead of spending time on this.

@naftaly naftaly closed this Sep 15, 2025
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

0