backtrace-labs / crashpad

A fork of Crashpad with file attachment support and other improvements.
Apache License 2.0
99 stars 33 forks source link

Repeated errors from crashpad about missing attachments/reports. #52

Open alecazam opened 1 year ago

alecazam commented 1 year ago

Getting these messages when we have an abort() as we're shutting down our app. If I manually erase the crash_reports directory, these go away for a little while. But a few minutes later, this looks like it starts searching back in time (here at 9:44:46) and reporting all sorts of missing attachments and reports that don't exist.

We add one attachment Sky.log, and then there is the .dmp file. There are no docs on who's responsible for this directory, but seems like it could slowly fill a users hard drive with 8MB dmp files, and our 1mb logs.

The crash_reports directory just keeps adding attachments (our Sky.log files) and reports (dmp files). Isn't something supposed to erase this. Also StartHandler seems to create this directory which makes it look like the app has had a crash even when it hasn't.

Also this can't delete the directory but I don't think I have any files within it open.

[14560:49932:20231028,094446.297:ERROR filesystem_win.cc:130] GetFileAttributes crash_reports\attachments\a1f8ab84-380c-4fe0-8ac9-0c608cdd36b1: The system cannot find the file specified. (2) [14560:49932:20231028,094446.298:ERROR filesystem_win.cc:130] GetFileAttributes crash_reports\attachments\ec0ae2b1-e371-4d5c-b27c-e571390db5c4: The system cannot find the file specified. (2) [14560:49932:20231028,094446.298:ERROR filesystem_win.cc:130] GetFileAttributes crash_reports\attachments\a04ee8cf-52e2-4322-9875-44fbd38e0ad3: The system cannot find the file specified. (2) [14560:38840:20231028,094446.298:ERROR filesystem_win.cc:130] GetFileAttributes crash_reports\attachments\a1f8ab84-380c-4fe0-8ac9-0c608cdd36b1: The system cannot find the file specified. (2) [14560:38840:20231028,094446.298:ERROR filesystem_win.cc:130] GetFileAttributes crash_reports\attachments\ec0ae2b1-e371-4d5c-b27c-e571390db5c4: The system cannot find the file specified. (2) [14560:38840:20231028,094446.299:ERROR filesystem_win.cc:130] GetFileAttributes crash_reports\attachments\a04ee8cf-52e2-4322-9875-44fbd38e0ad3: The system cannot find the file specified. (2)

This is missing a period. Should be reporting13d94c0c-e8f1-4e2e-8a6a-453cedef1930.dmp? [14560:38840:20231028,094446.299:ERROR filesystem_win.cc:117] GetFileAttributes crash_reports\reports\13d94c0c-e8f1-4e2e-8a6a-453cedef1930dmp: The system cannot find the file specified. (2) [14560:38840:20231028,094446.300:ERROR filesystem_win.cc:117] GetFileAttributes crash_reports\reports\cc7931d8-dde0-44ad-96a2-8be55455f1d5dmp: The system cannot find the file specified. (2)

This looks bad [14560:38840:20231028,094446.301:ERROR filesystem_win.cc:48] RemoveDirectory crash_reports\attachments\cc7931d8-dde0-44ad-96a2-8be55455f1d5: The process cannot access the file because it is being used by another process. (32)

[14560:38840:20231028,094446.301:ERROR filesystem_win.cc:130] GetFileAttributes crash_reports\attachments\a1f8ab84-380c-4fe0-8ac9-0c608cdd36b1: The system cannot find the file specified. (2) [14560:38840:20231028,094446.301:ERROR filesystem_win.cc:130] GetFileAttributes crash_reports\attachments\ec0ae2b1-e371-4d5c-b27c-e571390db5c4: The system cannot find the file specified. (2) [14560:38840:20231028,094446.302:ERROR filesystem_win.cc:130] GetFileAttributes crash_reports\attachments\a04ee8cf-52e2-4322-9875-44fbd38e0ad3: The system cannot find the file specified. (2) [14560:38840:20231028,094446.304:ERROR filesystem_win.cc:130] GetFileAttributes crash_reports\attachments\13d94c0c-e8f1-4e2e-8a6a-453cedef1930: The system cannot find the file specified. (2)

alecazam commented 1 year ago

One thing is we had the database init in a local unique_ptr, and so it was getting destroyed at the end of the function scope that called StartHandler. So will see if the above issues are gone now.

But still have the issue of these dmp/log files accumulating in this directory. The sample app doesn't indicate anything about this issue.

alecazam commented 1 year ago

After running this an hour later, all the error strings are back, and there are a lot of them. Just like above.

alecazam commented 1 year ago

This seems to delete the attachments (logs in our case), but not the reports or metadata. And the errors about missing attachments are at like 30 on my machine, even with 0 in the folder, and only 10 reports (dmp) files.

Crashpad

                // this creates a new crash_reports folder, or loads the old one
                database = CrashReportDatabase::Initialize( params.db );

                // Cleanup the existing files, or they'll just build and report a ton of errors
        _tzset(); // set timezone
        time_t localTime;
        ::time( &localTime );

        int reportsRemoved = database->CleanDatabase( localTime );

I delete crash_reports folder, then ran it once, and crashed for this test.

  1. crashpad generated this reports/guid.dmp, which gets added into reports, the attachments/guid/app.log. and writes that guild.dmp into the metadata file.
  2. running a second time
  3. crashpad StartHandler, deletes the attachments/guid folder which is great, but it leaves the old guid.dmp file, and doesn't clear the metadata. So then I get these error from StartHander. These build and build as the metdata file accumulates more and more guids.

This error is the guid attachment from step 1, that was deleted by CleanDatabases(), but these errors still fire even without doing the Clean.

[15628:55460:20231028,224011.318:ERROR filesystem_win.cc:130] GetFileAttributes crash_reports\attachments\8116ac01-c284-46fc-86f8-6421f45e3e41: The system cannot find the file specified. (2)

alecazam commented 1 year ago

This seems to work, but is completely missing from the example code.

// get rid of all the old reports
        std::vector<CrashReportDatabase::Report> reports;

        reports.clear();
        CrashReportDatabase::OperationStatus res = database->GetCompletedReports(&reports);
        if ( res == CrashReportDatabase::OperationStatus::kNoError )
        {
            for ( auto& report : reports )
            {
                database->DeleteReport( report.uuid );
            }
        }

        reports.clear();
        res = database->GetPendingReports(&reports);
        if ( res == CrashReportDatabase::OperationStatus::kNoError )
        {
            for ( auto& report : reports )
            {
                database->DeleteReport( report.uuid );
            }
        }
gm4sl commented 1 year ago

Thanks @alecazam. We'll get this included in the documentation and example code. Really appreciate your help.