[SERVER-17752] Application verifier - Winsock API was called before a successful WSAStartup() Created: 26/Mar/15  Updated: 18/Sep/15  Resolved: 27/Mar/15

Status: Closed
Project: Core Server
Component/s: Internal Code, Networking
Affects Version/s: 3.1.0
Fix Version/s: 3.1.1

Type: Bug Priority: Major - P3
Reporter: Eitan Klein Assignee: Mark Benvenuto
Resolution: Done Votes: 0
Labels: 32qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: Windows
Steps To Reproduce:

1) Install application verifier
2) Use MongoD enterprise end (linked to MSVCRT)
3) Configure application verifier and enable network test

Sprint: Platform 1 04/03/15
Participants:

 Description   

version
db version v3.1.1-pre-
git version: 5e7aa5c9efdea28cc82ff8d0ea0e3a76cf5c94f8
OpenSSL version: OpenSSL 1.0.1m-fips 19 Mar 2015

Issue: MongoD failed to start when application verifier enabled w/ networking check b/c call to sock without initialize it first

About the tool
http://www.microsoft.com/en-us/download/details.aspx?id=20028
environment:
Single mongod

Problem:
A Winsock API was called before a successful WSAStartup() or after a balancing successful WSACleanup() call was made

Problem happen with the stack trace described below

 
Microsoft (R) Windows Debugger Version 6.3.9600.17298 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.
 
*******************************************************************************
*                                                                             *
*                        Exception Analysis                                   *
*                                                                             *
*******************************************************************************
 
*** WARNING: Unable to verify checksum for C:\mongodb-win32-x86_64-enterprise-windows-64-875b0c2c020e0d6cd88a9b3fad5625b8e82b31cb-2015-03-20\bin\mongod.exe
APPLICATION_VERIFIER_NETWORKING_WSA_NOT_INITIALIZED (e107)
A Winsock API was called before a successful WSAStartup() or after a balancing successful WSACleanup() call was made
A call was made to a networking API before a successful WSAStarup() or after a balancing successful WSACleanup() call. WSAStartup is required to provide a reference count by any component using Winsock to guarantee initialization for Winsock API usage. An unbalance WSAStartup/WSACleanup call pattern by a component can lead to undefined behavior as this can cause the Winsock layer to unload libraries and release resources while still being used. 
Arguments:
Arg1: 0000000000000000, Last sucessfull WSAStartup call by this caller. Use dps to dump the stack if not NULL 
Arg2: 0000000000000000, Last sucessfull WSACleanup call by this caller. Use dps to dump the stack if not NULL 
Arg3: 0000000000000000, Last successful WSAStartup call in this process. Use dps to dump the stack if not NULL 
Arg4: 0000000000000000, Last sucessfull WSACleanup call in this process. Use dps to dump the stack if not NULL 
 
FAULTING_IP: 
vrfcore!VerifierStopMessageEx+6f4
00007ff8`331b3a00 cc              int     3
 
EXCEPTION_RECORD:  ffffffffffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 00007ff8331b3a00 (vrfcore!VerifierStopMessageEx+0x00000000000006f4)
   ExceptionCode: 80000003 (Break instruction exception)
  ExceptionFlags: 00000000
NumberParameters: 1
   Parameter[0]: 0000000000000000
 
CONTEXT:  0000000000000000 -- (.cxr 0x0;r)
rax=00007ff8331c4930 rbx=000000b97209f590 rcx=00007ff700fcd000
rdx=000000b97209df20 rsi=0000000000000000 rdi=0000000000000000
rip=00007ff8331b3a00 rsp=000000b97209f660 rbp=000000b97209f700
 r8=0000000000000000  r9=000000b97209de68 r10=00007ff8331c38d0
r11=0000000000000001 r12=0000000000000000 r13=0000000000000002
r14=0000000000000000 r15=0000000000000000
iopl=0         nv up ei pl nz na pe nc
cs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000200
vrfcore!VerifierStopMessageEx+0x6f4:
00007ff8`331b3a00 cc              int     3
 
FAULTING_THREAD:  0000000000000dd4
 
DEFAULT_BUCKET_ID:  STATUS_BREAKPOINT
 
PROCESS_NAME:  mongod.exe
 
ERROR_CODE: (NTSTATUS) 0x80000003 - {EXCEPTION}  Breakpoint  A breakpoint has been reached.
 
EXCEPTION_CODE: (HRESULT) 0x80000003 (2147483651) - One or more arguments are invalid
 
EXCEPTION_PARAMETER1:  0000000000000000
 
NTGLOBALFLAG:  2000100
 
APPLICATION_VERIFIER_FLAGS:  81643277
 
APP:  mongod.exe
 
ANALYSIS_VERSION: 6.3.9600.17298 (debuggers(dbg).141024-1500) amd64fre
 
PRIMARY_PROBLEM_CLASS:  STATUS_BREAKPOINT
 
BUGCHECK_STR:  APPLICATION_FAULT_STATUS_BREAKPOINT
 
LAST_CONTROL_TRANSFER:  from 00007ff8353a26f5 to 00007ff8331b3a00
 
STACK_TEXT:  
000000b9`7209f660 00007ff8`353a26f5 : 000000b9`77d435a0 000000b9`77d35440 00007ff7`01c20000 000000b9`77d35440 : vrfcore!VerifierStopMessageEx+0x6f4
000000b9`7209f9c0 00007ff8`353a27b0 : 000000b9`77d1f450 000000b9`7209fab8 000000b9`77d35440 00000000`0000000a : vfnet!NetTrackStartup::StopIfNotInitialized+0x295
000000b9`7209fa20 00007ff8`353ab875 : 00007ff8`353a1280 000000b9`7209fab0 00000000`00000000 00000000`00000007 : vfnet!NetWSAInitTracker::StopIfNotInitialized+0x40
000000b9`7209fa50 00007ff7`021bf89a : 00000000`00000000 000000b9`7209fb90 00007ff7`02a19a00 00000000`00000000 : vfnet!VfHookgetaddrinfo+0x4d
000000b9`7209fa90 00007ff8`2c7d276b : 00000000`00000d58 00000000`00000c29 00007ff7`025dbae8 00000000`00000d58 : mongod!mongo::SockAddr::SockAddr+0x24a
000000b9`7209fc30 00007ff7`02525ada : 00007ff7`02525ba8 00000000`00000000 00007ff7`00fcf000 00007ff7`02525ba8 : MSVCR120!initterm+0x3f
000000b9`7209fc60 00007ff8`448013d2 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : mongod!__tmainCRTStartup+0xa2
000000b9`7209fc90 00007ff8`46eee954 : 00007ff8`448013b0 00000000`00000000 00000000`00000000 00000000`00000000 : KERNEL32!BaseThreadInitThunk+0x22
000000b9`7209fcc0 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x34
 
 
STACK_COMMAND:  .cxr 0x0 ; kb
 
FOLLOWUP_IP: 
vfnet!NetTrackStartup::StopIfNotInitialized+295
00007ff8`353a26f5 488b5c2460      mov     rbx,qword ptr [rsp+60h]
 
SYMBOL_STACK_INDEX:  1
 
SYMBOL_NAME:  vfnet!NetTrackStartup::StopIfNotInitialized+295
 
FOLLOWUP_NAME:  MachineOwner
 
MODULE_NAME: vfnet
 
IMAGE_NAME:  vfnet.dll
 
DEBUG_FLR_IMAGE_TIMESTAMP:  5215f777
 
FAILURE_BUCKET_ID:  STATUS_BREAKPOINT_80000003_vfnet.dll!NetTrackStartup::StopIfNotInitialized
 
BUCKET_ID:  APPLICATION_FAULT_STATUS_BREAKPOINT_vfnet!NetTrackStartup::StopIfNotInitialized+295
 
ANALYSIS_SOURCE:  UM
 
FAILURE_ID_HASH_STRING:  um:status_breakpoint_80000003_vfnet.dll!nettrackstartup::stopifnotinitialized
 
FAILURE_ID_HASH:  {1df460fb-da09-30ef-a645-25f2b731ebd6}
 
Followup: MachineOwner
---------
 
0:000> 



 Comments   
Comment by Githook User [ 27/Mar/15 ]

Author:

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

Message: SERVER-17752: Winsock API was called before a successful WSAStartup()
Branch: master
https://github.com/mongodb/mongo/commit/d99002b06e3f20cb074da7f5aca68423990139cf

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