-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
AppVerifier: VERIFIER_STOP during sentry_shutdown() #488
Comments
I notice two things here:
|
I re-tested this issue with version 0.4.7 and with AppVerifier flag "Leak" active, I still get this error.
From debugging I see, that this code is the one opening the critical section:
sentry_bgworker_t *
sentry__bgworker_new(void *state, void (*free_state)(void *state))
{
sentry_bgworker_t *bgw = SENTRY_MAKE(sentry_bgworker_t);
if (!bgw) {
if (free_state) {
free_state(state);
}
return NULL;
}
memset(bgw, 0, sizeof(sentry_bgworker_t));
sentry__mutex_init(&bgw->task_lock); // <= This seems to be the init of the critical section that is later not cleaned
sentry__cond_init(&bgw->submit_signal);
sentry__cond_init(&bgw->done_signal);
bgw->state = state;
bgw->free_state = free_state;
bgw->refcount = 1;
return bgw;
} Best regards, |
@Swatinem I've updated my comment |
The Can you double check this? |
Hello @Swatinem I've double checked. I was using the correct version 0.4.7. In fact I am installing sentry-native via vcpkg package manager. I checked the build logs and files. vcpkg was building the version 0.4.7 and I linked it in my project correctly. For reproduction it is important, that you specify the AppVerifier setting "Leak". This are the steps to reproduce I would suggests:
|
I was playing around with this just now, but still can’t reproduce your failure. However, I was able to reproduce a different verified failure thats fixed here: #492 Sentry is using quite a few static mutexes, and the only non-static one is the |
Hi Swatinem, Thank you for taking the time to investigate this issue. Turns out that the verifier stop is reported only if Sentry is being used from an explicitly loaded DLL. Please find attached an archive containing the following files:
I've built the code using VS 2019 for the Release x64 build configuration. Here are the steps I've followed to repro the issue:
Please let us know if you were able to repro the issue. |
That might be the explanation. Sentry uses some static locks which are being initialized lazily. And not being properly freed because of that. I’m not yet aware how to properly manage the lifecycle of static mutexes on Windows, will have to find that out first. |
Hi @Swatinem, Do you have any progress on this ticket? Can you please share an update? |
I have looked at this a bit, but didn’t start actually solving this yet. |
Hello @Swatinem, one of the things we've noticed, which might impact this issue, is the fact that
the wait time is 2 seconds, which, if there's an active envelope to be sent, is not enough. We routinely see in our tests that the messages to be sent take 2.5 to 4 seconds. What happens is that we're calling As a fix, I would suggest increasing the SENTRY_DEFAULT_SHUTDOWN_TIMEOUT to a very permissive value of 1 minute or even more. This change should NOT influence the normal flow shutdown, because is based on task wait, and in case of an abnormal timeout, the issue becomes more visible and can be reported by the users. |
Hm, this ties in with #568 as well.
Thanks for investigating! This has helped a lot understanding where this was coming from. I was not able to reproduce the verifier failure before. |
Should we prepare a PR, or is it something you plan to do? |
I think you can try to work on a PR to make the shutdown timeout configurable, it should be easy enough. I think creating an explicit flush hook on the transport might be a bit more complicated. |
I would like to do this, but there's no "Create Branch" option available for me. Do I need to have some permissions? |
Not sure what you are trying to do? Usually you just fork and create a PR from there? |
thats good to hear |
Description
We are running the most simple test application on Windows 10 that reports an event to Sentry containing a simple text message.
We're performing tests with AppVerifier. The message is reported successfully to Sentry.
However we get a VERIFIER_STOP assertion when sentry_shutdown() is executed.
VERIFIER STOP 0000000000000202: pid 0x4B8: Freeing heap block containing an active critical section.
When does the problem happen
In the call to sentry_shutdown() when executing with AppVerifier turned on.
Environment
Sentry test server deployed within our organization
Steps To Reproduce
1. Enable AppVerifier for test app.
2. AppVerifier settings:
3. Run application with Windbg attached.
4. Code
Log output
[sentry] INFO using database path "C:\Users\user.name\source\repos\SentryCustomTransport\SentryCustomTransport.sentry-native"
[sentry] DEBUG starting transport
[sentry] DEBUG starting background worker thread
[sentry] DEBUG background worker thread started
sending event
[sentry] DEBUG merging scope into event
[sentry] DEBUG adding attachments to envelope
[sentry] DEBUG sending envelope
[sentry] DEBUG submitting task to background worker thread
[sentry] DEBUG executing task on worker thread
[sentry] DEBUG sending envelope
[sentry] DEBUG submitting task to background worker thread
[sentry] DEBUG shutting down transport
[sentry] DEBUG shutting down background worker thread
[sentry] DEBUG submitting task to background worker thread
[sentry] DEBUG sending request using winhttp to "https://sentry.company.net:443/api/47/envelope/":
x-sentry-auth:Sentry sentry_key=***********************, sentry_version=7, sentry_client=sentry.native/0.4.3
content-type:application/x-sentry-envelope
content-length:5566
[sentry] DEBUG received response:
HTTP/1.1 200 OK
Connection: keep-alive
Date: Fri, 26 Feb 2021 12:09:38 GMT
Content-Length: 41
Content-Type: application/json
Server: nginx
Vary: Origin
access-control-expose-headers: retry-after, x-sentry-error, x-sentry-rate-limits
Strict-Transport-Security: max-age=31536000
[sentry] DEBUG request handled in 179ms
[sentry] DEBUG executing task on worker thread
[sentry] DEBUG sending request using winhttp to "https://sentry.company.net:443/api/47/envelope/":
x-sentry-auth:Sentry sentry_key=***********************, sentry_version=7, sentry_client=sentry.native/0.4.3
content-type:application/x-sentry-envelope
content-length:308
[sentry] DEBUG received response:
HTTP/1.1 200 OK
Connection: keep-alive
Date: Fri, 26 Feb 2021 12:09:38 GMT
Content-Length: 2
Content-Type: application/json
Server: nginx
Vary: Origin
access-control-expose-headers: x-sentry-rate-limits, retry-after, x-sentry-error
Strict-Transport-Security: max-age=31536000
[sentry] DEBUG request handled in 48ms
[sentry] DEBUG executing task on worker thread
[sentry] DEBUG background worker thread shut down
AppVerifier output
=======================================
VERIFIER STOP 0000000000000202: pid 0x4E8: Freeing heap block containing an active critical section.
=======================================
This verifier stop is continuable.
After debugging it use `go' to continue.
=======================================
(4e8.88c): Break instruction exception - code 80000003 (first chance)
vrfcore!VerifierStopMessageEx+0x806:
00007ffe`e5b326e6 cc int 3
0:000> Kb 100
RetAddr : Args to Child : Call Site
00 00007ffe
df2f51b3 : 00000000
01000002 000001e91b700000 000001e9
1b701000 00007ffedf3e2902 : vrfcore!VerifierStopMessageEx+0x806 01 00007ffe
df2f3ae4 : 0000000000000070 00000000
00000000 0000000000000000 000001e9
1b701000 : vfbasics+0x51b302 00007ffe
df3061f8 : 000001e9
20c1bf90 0000000d6334f6d9 00000000
00000070 000001e91b700000 : vfbasics+0x3ae4 03 00007ff7
aeddb628 : 000001e91b700000 000001e9
00000000 000001e920c1bf90 00007ffe
f41f5570 : vfbasics+0x161f804 00007ff7
aedbc722 : 000001e9
1b700000 0000000000000000 000001e9
20ec6ff0 00007ffef41f5570 : SentryTest!_free_base+0x1c [minkernel\crts\ucrt\src\appcrt\heap\free_base.cpp @ 105] 05 00007ff7
aedbb90c : 000001e920c1dfc0 00000000
00000000 000001e920c31ff0 00007ffe
f41f5570 : SentryTest!sentry__bgworker_decref+0x92 [\vcpkg\buildtrees\sentry-native\src\y-native-0-a09cff82c7.clean\src\sentry_sync.c @ 111]06 00007ff7
aedb532d : 00000000
6038e41c 0000000000000000 0000a7de
d781cd0c 0000000000000011 : SentryTest!sentry_transport_free+0x1c [\vcpkg\buildtrees\sentry-native\src\y-native-0-a09cff82c7.clean\src\sentry_transport.c @ 129] 07 00007ff7
aedb5278 : 000001e920bb3f60 00000000
00000000 00000010701749b2 0000000d
6334f6d9 : SentryTest!sentry_options_free+0x7d [\vcpkg\buildtrees\sentry-native\src\y-native-0-a09cff82c7.clean\src\sentry_options.c @ 82]08 00007ff7
aedb21ea : 000001e9
21a37ff0 0000000d00000000 00000000
00000011 000001e920bb3f60 : SentryTest!sentry_shutdown+0xd8 [\vcpkg\buildtrees\sentry-native\src\y-native-0-a09cff82c7.clean\src\sentry_core.c @ 205] 09 00007ff7
aedc0074 : 000001e920b0cfd0 00000000
00000000 000001e920b12ea0 00000000
00000000 : SentryTest!main+0x31a [\source\repos\SentryCustomTransport\SentryCustomTransport\SentryCustomTransport.cpp @ 41]0a (Inline Function) : --------
-------- --------
-------- ---------------- --------
-------- : SentryTest!invoke_main+0x22 [d:\agent_work\63\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 78]0b 00007ffe
f41f7034 : 00000000
00000000 0000000000000000 00000000
00000000 0000000000000000 : SentryTest!__scrt_common_main_seh+0x10c [d:\agent\_work\63\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 288] 0c 00007ffe
f433d241 : 0000000000000000 00000000
00000000 0000000000000000 00000000
00000000 : KERNEL32!BaseThreadInitThunk+0x140d 00000000
00000000 : 00000000
00000000 0000000000000000 00000000
00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21The text was updated successfully, but these errors were encountered: