[SERVER-21010] Closing a command prompt running mongo.exe client causes app crash Created: 19/Oct/15  Updated: 08/Jan/24  Resolved: 06/Nov/15

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.2.0-rc0
Fix Version/s: 3.2.0-rc3

Type: Bug Priority: Major - P3
Reporter: Dave S Assignee: Mark Benvenuto
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 x64 for the client. Tested against server running 2.6.8 on Win 2012 R2 and on local server running 3.2RC0 on the same Windows 7 box.


Attachments: PNG File mongocrash.png    
Issue Links:
Duplicate
is duplicated by SERVER-21759 Mongo Shell Crashes in Windows when c... Closed
Backwards Compatibility: Fully Compatible
Operating System: Windows
Steps To Reproduce:

On a windows 7 environment, run the command promopt, then run mongo.exe and connect to a mongo server (with or without auth). Then click the top-right X on the command prompt window. mongo.exe will crash producing a "mongo.exe has stopped working" windows dialog.

Sprint: Platform B (10/30/15), Platform C (11/20/15)
Participants:

 Description   

mongo.exe doesn't handle the X to close the app/command prompt it was opened in.



 Comments   
Comment by Ramon Fernandez Marina [ 06/Nov/15 ]

Thanks for reporting this radardave. The fix has been committed and it will be part of the upcoming 3.2.0-rc3 release candidate, scheduled for the coming weeks.

Comment by Githook User [ 06/Nov/15 ]

Author:

{u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}

Message: SERVER-21010 Fix console Control-C handler on Posix Platforms
Branch: master
https://github.com/mongodb/mongo/commit/d393cfcf7fefe99b1ffba05ce6282bb5c97f20fb

Comment by Githook User [ 06/Nov/15 ]

Author:

{u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}

Message: SERVER-21010 Closing a command prompt running mongo.exe client causes app crash
Branch: master
https://github.com/mongodb/mongo/commit/76d008dddaf588a3cfbd1db53c8771e5f9364555

Comment by Mark Benvenuto [ 19/Oct/15 ]

Here is the stack. It repros with 3.2.0-rc0 mongo.exe and 3.2.0-rc0 mongod.exe on Windows 10.

0:023> .lastevent
Last event: 7794.102c: Unknown exception - code c000000d (!!! second chance !!!)
  debugger time: Mon Oct 19 13:40:59.615 2015 (UTC - 4:00)
0:023> k
 # Child-SP          RetAddr           Call Site
00 000000bc`923ff770 00007ffb`72959e6d ntdll!TppRaiseInvalidParameter+0x48
01 000000bc`923ff850 00007ffb`700028da ntdll!TpAllocWait+0x6543d
02 000000bc`923ff8a0 00007ffb`392272e1 KERNEL32!CreateThreadpoolWaitStub+0x1a
03 (Inline Function) --------`-------- MSVCR120!Concurrency::details::RegisterAsyncWaitAndLoadLibrary+0x12 [f:\dd\vctools\crt\crtw32\concrt\utils.cpp @ 673]
04 000000bc`923ff8d0 00007ffb`392349d3 MSVCR120!Concurrency::details::ExternalContextBase::PrepareForUse+0xa1 [f:\dd\vctools\crt\crtw32\concrt\externalcontextbase.cpp @ 120]
05 (Inline Function) --------`-------- MSVCR120!Concurrency::details::SchedulerBase::GetExternalContext+0x52 [f:\dd\vctools\crt\crtw32\concrt\schedulerbase.cpp @ 1638]
06 000000bc`923ff980 00007ffb`39233c06 MSVCR120!Concurrency::details::SchedulerBase::AttachExternalContext+0xe3 [f:\dd\vctools\crt\crtw32\concrt\schedulerbase.cpp @ 1585]
07 000000bc`923ff9d0 00007ffb`392222da MSVCR120!Concurrency::details::SchedulerBase::CreateContextFromDefaultScheduler+0xfe [f:\dd\vctools\crt\crtw32\concrt\schedulerbase.cpp @ 573]
08 000000bc`923ffa20 00007ffb`3922ae32 MSVCR120!Concurrency::details::SchedulerBase::CurrentContext+0x26 [f:\dd\vctools\crt\crtw32\concrt\schedulerbase.h @ 404]
09 (Inline Function) --------`-------- MSVCR120!Concurrency::details::LockQueueNode::{ctor}+0x24 [f:\dd\vctools\crt\crtw32\concrt\rtlocks.cpp @ 619]
0a 000000bc`923ffa50 00007ffb`42dbcd49 MSVCR120!Concurrency::critical_section::lock+0x2a [f:\dd\vctools\crt\crtw32\concrt\rtlocks.cpp @ 1031]
0b 000000bc`923ffab0 00007ff6`17b6698c MSVCP120!mtx_do_lock+0x85 [f:\dd\vctools\crt\crtw32\stdcpp\thr\mutex.c @ 67]
0c 000000bc`923ffb00 00007ffb`39242925 mongo!mongo::`anonymous namespace'::ReplicaSetMonitorWatcher::~ReplicaSetMonitorWatcher+0x3c [c:\data\mci\src\src\mongo\client\replica_set_monitor.cpp @ 87]
0d 000000bc`923ffb40 00007ffb`39242ade MSVCR120!doexit+0x145 [f:\dd\vctools\crt\crtw32\startup\crt0dat.c @ 628]
0e 000000bc`923ffbb0 00007ffb`728d3d70 MSVCR120!__CRTDLL_INIT+0xce [f:\dd\vctools\crt\crtw32\dllstuff\crtlib.c @ 325]
0f 000000bc`923ffbe0 00007ffb`728f638a ntdll!LdrpCallInitRoutine+0x4c
10 000000bc`923ffc40 00007ffb`728f6224 ntdll!LdrShutdownProcess+0x14a
11 000000bc`923ffd50 00007ffb`6fda56cf ntdll!RtlExitUserProcess+0xb4
12 000000bc`923ffd80 00007ffb`6fda5674 KERNELBASE!DefaultHandler+0xf
13 000000bc`923ffdb0 00007ffb`6fff2d92 KERNELBASE!CtrlRoutine+0xb4
14 000000bc`923ffea0 00007ffb`728b9f64 KERNEL32!BaseThreadInitThunk+0x22
15 000000bc`923ffed0 00000000`00000000 ntdll!RtlUserThreadStart+0x34

We need to add a HandlerRoutine, handle CTRL_CLOSE_EVENT, and simply call _exit. I will follow up with mira.carey@mongodb.com if there are any issues with that plan.

Generated at Thu Feb 08 03:55:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.