develooper Front page | perl.perl5.porters | Postings from May 2013

[perl #118127] Perl crash when run under AppVerifier

Thread Previous
From:
Karthik Rajagopalan
Date:
May 23, 2013 00:06
Subject:
[perl #118127] Perl crash when run under AppVerifier
Message ID:
rt-3.6.HEAD-2650-1369256258-779.118127-75-0@perl.org
# New Ticket Created by  Karthik Rajagopalan 
# Please include the string:  [perl #118127]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=118127 >


Hi Folks,

We use perl widely for one of our job monitoring application. And recently
we received reports from customer that the application crash after few
hours with 'invalid handle' exception in ntdll.dll.
So we planned to run our application in Application Verifier of Windows to
trace handles and having a hard time to run perl under it. Currently the
following piece of code extracted in the form of a sample script crash
under AppVerifier -

use IO::Socket::INET;
use IPC::Open2;
my $log = "txt";
open OUT, -f $log ? ">> $log" : ">$log";

# Pass an open handle of tempfile to child process.
open FILE, ">temp";
binmode FILE;
print FILE "abc";
close FILE;
open IN, "temp";

print "here\n";
my $child_pid = open2(">&OUT","<&IN","(notepad.exe)2>&1");
print "here1\n";
close IN;
close OUT;

Exactly after notepad.exe process is spawned we see the crash with
following stack trace. We see a similar trace at customer site when a
handle is being closed through closesocket(..) call which is not really a
socket handle. The stack trace given below is from perl-5.10.1. We also see
a similar stack trace with 5.14.2. So I am sure this is a problem even in
current running version of perl. Can you please take a look and respond
back?

-Karthik



0:000> !analyze  -v
*******************************************************************************
*
  *
*                        Exception Analysis
  *
*
  *
*******************************************************************************

*** WARNING: Unable to verify checksum for
c:\Schrodinger2012_x64\latest\mmshare-v2.1\bin\Windows-x64\perl510.dll
*** WARNING: Unable to verify checksum for
c:\Schrodinger2012_x64\latest\mmshare-v2.1\bin\Windows-x64\perl.exe
APPLICATION_VERIFIER_HANDLES_INVALID_HANDLE (300)
Invalid handle exception for current stack trace.
This stop is generated if the function on the top of the stack passed an
invalid handle to system routines. Usually a simple kb command will reveal
what is the value of the handle passed (must be one of the parameters -
usually the first one). If the value is null then this is clearly wrong.
If the value looks ok you need to use !htrace debugger extension to get a
history of operations pertaining to this handle value. In most cases it
must be that the handle value is used after being closed.
Arguments:
Arg1: 00000000c0000008, Exception code.
Arg2: 000000000108eaa0, Exception record. Use .exr to display it.
Arg3: 000000000108e470, Context record. Use .cxr to display it.
Arg4: 0000000000000000, Not used.

FAULTING_IP:
vrfcore!VerifierStopMessageEx+779
000007fe`f76637ed cc              int     3

EXCEPTION_RECORD:  000000000108eaa0 -- (.exr 0x108eaa0)
ExceptionAddress: 0000000077c5fec7
(ntdll!KiRaiseUserExceptionDispatcher+0x000000000000003a)
   ExceptionCode: c0000008 (Invalid handle)
  ExceptionFlags: 00000000
NumberParameters: 0
Thread tried to close a handle that was invalid or illegal to close

FAULTING_THREAD:  0000000000000ae8

DEFAULT_BUCKET_ID:  STATUS_BREAKPOINT

PROCESS_NAME:  perl.exe

CONTEXT:  000000000108e470 -- (.cxr 0x108e470)
rax=0000000031c7226f rbx=0000000000000000 rcx=000000000108e470
rdx=000007fef5663da5 rsi=0000000000000000 rdi=0000000000000003
rip=0000000077c5fec7 rsp=000000000108ea80 rbp=000000000108ebd0
 r8=000000000108eb48  r9=000000000108ebd0 r10=0000000000000000
r11=0000000000000202 r12=0000000000000000 r13=0000000000000000
r14=0000000000000000 r15=0000000000012043
iopl=0         nv up ei pl nz na po nc
cs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b
efl=00000206
ntdll!KiRaiseUserExceptionDispatcher+0x3a:
00000000`77c5fec7 8b8424c0000000  mov     eax,dword ptr [rsp+0C0h]
ss:00000000`0108eb40=c0000008
Resetting default scope

BAD_HANDLE: 0000000000000003 (!htrace 0000000000000003)

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

MOD_LIST: <ANALYSIS/>

NTGLOBALFLAG:  100

APPLICATION_VERIFIER_FLAGS:  80000004

PRIMARY_PROBLEM_CLASS:  STATUS_BREAKPOINT

BUGCHECK_STR:  APPLICATION_FAULT_STATUS_BREAKPOINT

LAST_CONTROL_TRANSFER:  from 000007fef56578dd to 000007fef76637ed

STACK_TEXT:
00000000`0108d970 000007fe`f56578dd : 00000000`0108dd10 00000000`77d48350
00000030`00000004 00000001`002b0000 : vrfcore!VerifierStopMessageEx+0x779
00000000`0108dca0 00000000`77c28a8f : 00000000`028f0dc0 00000000`eceeae86
00000000`77d48350 00000000`0618ccf9 :
vfbasics!AVrfpVectoredExceptionHandler+0x85
00000000`0108dcf0 00000000`77c259b2 : 00000000`0000000e 00000000`00000000
00000000`00000080 00000000`028f0db0 : ntdll!RtlpCallVectoredHandlers+0xa8
00000000`0108dd60 00000000`77c262ee : 00000000`00000000 00000000`00000000
00000000`00000001 000007fe`00000015 : ntdll!RtlDispatchException+0x22
00000000`0108e440 00000000`77c5fec7 : 00000000`00000000 00000000`00000000
00000000`00000003 00000000`00033283 : ntdll!RtlRaiseException+0x221
00000000`0108ea80 000007fe`f5663da5 : 00000000`00000003 00000000`0108ec18
00000000`0108ec20 00000000`0108ec28 :
ntdll!KiRaiseUserExceptionDispatcher+0x3a
00000000`0108eb50 000007fe`fd3c80d8 : 00000000`00000000 00000000`00000370
00000000`00000000 00000000`00000000 :
vfbasics!AVrfpNtDeviceIoControlFile+0x171
00000000`0108ec10 000007fe`fd3abfe0 : 00000000`00000003 00000000`05941380
00000000`00000003 00000000`00000001 : mswsock!SockImportHandle+0x108
00000000`0108ee00 000007fe`fd3cbd19 : 00000000`00000003 00000000`05941380
00000000`00000006 00000000`02b57bf8 : mswsock!_GSHandlerCheck_SEH+0x408a
00000000`0108ee30 000007fe`fe797b7e : 00000000`00000003 000007fe`0000ffff
00000000`00000003 00000000`05941380 : mswsock!WSPGetSockOpt+0x99
00000000`0108ef10 000007fe`fe7ad71a : 00000000`05945590 00000000`00000000
00000000`05941380 00000000`02b50000 : WS2_32!DPROVIDER::WSPGetSockOpt+0x3e
00000000`0108ef50 000007fe`fe7ad7f0 : 00000000`00000208 00000000`00003c30
00000000`00000000 000007fe`fe781ac0 :
WS2_32!DCATALOG::FindIFSProviderForSocket+0xca
00000000`0108f260 000007fe`fe7903fd : 00000000`00000001 00000000`00000000
00000000`00000000 000007fe`f565a64d : WS2_32!DSOCKET::FindIFSSocket+0x40
00000000`0108f290 00000000`6b8e4756 : 00000000`00000000 00000000`00000000
00000000`02b57bf8 00000000`00000001 : WS2_32!_chkstk+0x3ecb
00000000`0108f2e0 00000000`6b8f70da : 00000000`00000000 00000000`06107358
00000000`02b57bf8 00000000`040015b0 : perl510!my_close+0x36
[c:\perl\perl_with_fix-5.10.1\win32\win32sck.c @ 470]
00000000`0108f310 00000000`6b8f2a51 : 00000000`06107358 00000000`02b57bf8
00000000`040015b0 00000000`00000001 : perl510!PerlIOUnix_close+0x5a
[c:\perl\perl_with_fix-5.10.1\perlio.c @ 2751]
00000000`0108f340 00000000`6b8f3257 : 00000000`040015b0 00000000`00000008
00000000`0108f4e0 00000000`6bdd8bc0 : perl510!PerlIOBase_close+0x91
[c:\perl\perl_with_fix-5.10.1\perlio.c @ 2181]
00000000`0108f370 00000000`6b8f37c7 : 00000000`00000008 00000000`040015b0
00000000`00000000 00000000`00000000 : perl510!PerlIOBuf_close+0x17
[c:\perl\perl_with_fix-5.10.1\perlio.c @ 4088]
00000000`0108f3a0 00000000`6b9e4256 : 00000000`00000008 00000000`00000002
00000000`0108f4e0 00000000`00000008 : perl510!Perl_PerlIO_close+0x37
[c:\perl\perl_with_fix-5.10.1\perlio.c @ 1432]
00000000`0108f3e0 00000000`6b96e84e : 00000000`04066440 00000000`6b980b3c
00000000`0615ec01 00000000`02b57bf8 : perl510!Perl_do_openn+0x1286
[c:\perl\perl_with_fix-5.10.1\doio.c @ 660]
00000000`0108f610 00000000`6b9e7f9c : 00000000`00000013 00000000`00000000
00000000`00000000 00000000`02b57bf8 : perl510!Perl_pp_open+0x27e
[c:\perl\perl_with_fix-5.10.1\pp_sys.c @ 561]
00000000`0108f690 00000000`6b9a8c06 : 00000000`02b57bf8 00000000`03fb9ee0
00000000`00000001 00000000`03ec6660 : perl510!Perl_runops_standard+0x16c
[c:\perl\perl_with_fix-5.10.1\run.c @ 40]
00000000`0108f700 00000000`6b9a8e94 : 00000000`02b57bf8 00000000`00000000
00000000`0108f6e0 00000000`03fb9ee0 : perl510!S_run_body+0x116
[c:\perl\perl_with_fix-5.10.1\perl.c @ 2433]
00000000`0108f730 00000000`6b8fd324 : 00000000`03fb39a0 00000000`03fba5a0
00000000`03fb9ee0 00000000`00000000 : perl510!perl_run+0x264
[c:\perl\perl_with_fix-5.10.1\perl.c @ 2352]
00000000`0108f8a0 00000001`3f0411b2 : 00000000`00000001 00000000`00000000
00000000`00000000 00000000`00000000 : perl510!RunPerl+0x124
[c:\perl\perl_with_fix-5.10.1\win32\perllib.c @ 270]
00000000`0108fcf0 00000000`77b0f56d : 00000000`00000000 00000000`00000000
00000000`00000000 00000000`00000000 : perl!__tmainCRTStartup+0x11a
[f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crtexe.c @ 555]
00000000`0108fd20 00000000`77c43281 : 00000000`00000000 00000000`00000000
00000000`00000000 00000000`00000000 : kernel32!BaseThreadInitThunk+0xd
00000000`0108fd50 00000000`00000000 : 00000000`00000000 00000000`00000000
00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x1d


FOLLOWUP_IP:
mswsock!SockImportHandle+108
000007fe`fd3c80d8 448bf8          mov     r15d,eax

SYMBOL_STACK_INDEX:  7

SYMBOL_NAME:  mswsock!SockImportHandle+108

FOLLOWUP_NAME:  MachineOwner

MODULE_NAME: mswsock

IMAGE_NAME:  mswsock.dll

DEBUG_FLR_IMAGE_TIMESTAMP:  4a5bdfc4

STACK_COMMAND:  ~0s ; kb

FAILURE_BUCKET_ID:  STATUS_BREAKPOINT_80000003_mswsock.dll!SockImportHandle

BUCKET_ID:
 X64_APPLICATION_FAULT_STATUS_BREAKPOINT_mswsock!SockImportHandle+108

Followup: MachineOwner

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About