<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16608" name=GENERATOR></HEAD>
<BODY id=MailContainerBody
style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-TOP: 15px"
bgColor=#ffffff leftMargin=0 topMargin=0 name="Compose message area"
CanvasTabStop="true">
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=052370619-28032008>Hi,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=052370619-28032008> Yes, the DuplicateHandle() is definitely needed
when you are passing handles between two different procs (not required btw
parent and child proc - the inheritance depends on your choice when calling
CreateProcess()).</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=052370619-28032008> I have seen several code snippets using this
(DuplicateHandle()) trick to prevent socket handles from being
inherited. Since it works for you we will (after some testing) integrate the
change that you suggest (SetHandleInformation()) into MPICH2.
</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=052370619-28032008> Thanks for reporting the bug.</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=052370619-28032008></SPAN></FONT> </DIV>
<DIV><SPAN class=052370619-28032008><FONT face=Arial color=#0000ff
size=2>(Note: The developer of the code might not
have used the function so as to support windows versions <
XP/Srv2003. But we might not want that any more :) )</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=052370619-28032008><FONT face=Arial color=#0000ff
size=2>Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=052370619-28032008><FONT face=Arial color=#0000ff
size=2>Jayesh</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Calin Iaru [mailto:calin@dolphinics.com]
<BR><B>Sent:</B> Friday, March 28, 2008 1:06 PM<BR><B>To:</B>
mpich-discuss@mcs.anl.gov; Jayesh Krishna<BR><B>Cc:</B>
mpich-discuss@mcs.anl.gov<BR><B>Subject:</B> Re: [mpich-discuss] DuplicateHandle
on easy_create<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2>I was inaccurate in assuming that a handle needs
DuplicateHandle. I just performed some tests with SetHandleInformation(sock, 1,
0) and they look good. Instead of duplicating, you could consider
this.</FONT></DIV>
<DIV style="FONT: 10pt Tahoma">
<DIV><BR></DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=calin@dolphinics.com
href="mailto:calin@dolphinics.com">Calin Iaru</A> </DIV>
<DIV><B>Sent:</B> Friday, March 28, 2008 5:51 PM</DIV>
<DIV><B>To:</B> <A title=jayesh@mcs.anl.gov
href="mailto:jayesh@mcs.anl.gov">Jayesh Krishna</A> </DIV>
<DIV><B>Cc:</B> <A title=mpich-discuss@mcs.anl.gov
href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</A> </DIV>
<DIV><B>Subject:</B> Re: [mpich-discuss] DuplicateHandle on
easy_create</DIV></DIV></DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>Hi Jayesh,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV> <FONT face=Arial size=2>the application runs on 2
nodes and it is launched by mpiexec/smpd. I looked at some handle inheritance
articles and it appears that if an application wants to allow a handle to be
inherited, it has to call DuplicateHandle. If DuplicateHandle is not called,
then I would expect the handle not to be inherited. Why would you want the
handle to not be inherited? Is it because of security concerns?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Best regards,</FONT></DIV>
<DIV> <FONT face=Arial size=2>Calin</FONT></DIV>
<DIV style="FONT: 10pt Tahoma">
<DIV><BR></DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=jayesh@mcs.anl.gov
href="mailto:jayesh@mcs.anl.gov">Jayesh Krishna</A> </DIV>
<DIV><B>Sent:</B> Friday, March 28, 2008 5:20 PM</DIV>
<DIV><B>To:</B> <A title=calin@dolphinics.com
href="mailto:calin@dolphinics.com">'Calin Iaru'</A> </DIV>
<DIV><B>Cc:</B> <A title=mpich-discuss@mcs.anl.gov
href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</A> </DIV>
<DIV><B>Subject:</B> RE: [mpich-discuss] DuplicateHandle on
easy_create</DIV></DIV></DIV>
<DIV><BR></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=885381416-28032008>Hi,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=885381416-28032008> Hmm... looks to me that you are running your MPI
app as a singleton client (Without using mpiexec to launch the MPI
app).</SPAN></FONT></DIV>
<DIV><SPAN class=885381416-28032008><FONT face=Arial size=2> There is a lot
more work to be done regarding the singleton client implementation (And I think
you might have found a suble bug :) where the PMI_Init() gets called multiple
times). Let us know if you are running your MPI app as a singleton client and we
can discuss on the fix to your problem.</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><SPAN class=885381416-28032008><FONT face=Arial
size=2>Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=885381416-28032008><FONT face=Arial
size=2>Jayesh</FONT></SPAN></DIV>
<DIV><BR></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Calin Iaru [mailto:calin@dolphinics.com]
<BR><B>Sent:</B> Friday, March 28, 2008 10:33 AM<BR><B>To:</B> Jayesh Krishna;
'Calin Iaru'<BR><B>Cc:</B> mpich-discuss@mcs.anl.gov<BR><B>Subject:</B> Re:
[mpich-discuss] DuplicateHandle on easy_create<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2>I don't have the exact error message, but you can
see an exception being reported in the stack backtrace:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>0:000> k<BR>ChildEBP RetAddr <BR>0012f6f0
7ffe0304 ntdll!KiRaiseUserExceptionDispatcher+0x37<BR>0012f6f4 77f426cb
SharedUserData!SystemCallStub+0x4<BR>0012f6f8 71b21e1f
ntdll!NtDeviceIoControlFile+0xc<BR>0012f748 71b21f29
MSWSOCK!SockGetTdiHandles+0x5f<BR>0012f758 71b22071
MSWSOCK!SockNotifyHelperDll+0x25<BR>0012f7c8 71b30791
MSWSOCK!SockCloseSocket+0x1ec<BR>0012f7d8 71bf27c6
MSWSOCK!DeleteSockets+0x31<BR>0012f804 71b309b3
WS2HELP!WahEnumerateHandleContexts+0x92<BR>0012f828 71c0d89d
MSWSOCK!WSPCleanup+0x73<BR>0012f834 71c09c1a
WS2_32!DPROVIDER::WSPCleanup+0x1d<BR>0012f86c 71c02c22
WS2_32!CleanupProtocolProviders+0x23<BR>0012f884 71c06572
WS2_32!NSCATALOG::EnumerateCatalogItems+0x22<BR>0012f8a0 71c081b4
WS2_32!DPROCESS::~DPROCESS+0x6f<BR>0012f8b8 10172fe3
WS2_32!WSACleanup+0x40<BR>0012f8c8 100d0e2a nmpi!MPIDU_Sock_finalize+0x53
<BR>0012fd50 100cf01a nmpi!iPMI_Finalize+0x15a <BR>0012fd5c 100c9afe
nmpi!PMI_Finalize+0x1a <BR>0012fd6c 100a14bd nmpi!MPIDI_CH3_Finalize+0x7e
<BR>0012fdec 1003bac6 nmpi!MPID_Finalize+0x2dd <BR>0012fdfc 00401e0f
nmpi!PMPI_Finalize+0x96 </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>0:000> kb<BR>ChildEBP RetAddr Args to
Child
<BR>0012f6f0 7ffe0304 77f426cb 71b21e1f
00000328<BR>ntdll!KiRaiseUserExceptionDispatcher+0x37<BR>0012f6f4 77f426cb
71b21e1f 00000328 00000360 SharedUserData!SystemCallStub+0x4<BR>0012f6f8
71b21e1f 00000328 00000360 00000000 ntdll!NtDeviceIoControlFile+0xc</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>and here's how !htrace looks like on handle
0x328</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>0:000> !htrace
0x328<BR>--------------------------------------<BR>Handle = 0x00000328 - *** BAD
REFERENCE ***<BR>Thread ID = 0x00000c54, Process ID = 0x00000c50</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>0x71b21f29:
MSWSOCK!SockNotifyHelperDll+0x00000025<BR>0x71b30791:
MSWSOCK!DeleteSockets+0x00000031<BR>0x71b309b3:
MSWSOCK!WSPCleanup+0x00000073<BR>0x71c0d89d:
WS2_32!DPROVIDER::WSPCleanup+0x0000001d<BR>0x71c02c22:
WS2_32!NSCATALOG::EnumerateCatalogItems+0x00000022<BR>--------------------------------------<BR>Handle
= 0x00000328 - CLOSE<BR>Thread ID = 0x00000c54, Process ID =
0x00000c50</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>0x10174f88:
nmpi!easy_create+0x00000228<BR>0x101747cc:
nmpi!MPIDU_Sock_post_connect+0x0000011c<BR>0x100d04b1:
nmpi!uPMI_ConnectToHost+0x00000041<BR>0x100cfc8a:
nmpi!iPMI_Init+0x0000049a<BR>0x100cefd8: nmpi!PMI_Init+0x00000578<BR>0x100ca614:
nmpi!MPIDI_CH3_Init_process_group+0x00000034<BR>0x100caa6c:
nmpi!MPIDI_CH3_Init+0x0000003c<BR>0x100a3972:
nmpi!MPID_Init+0x000001b2<BR>0x10056bff:
nmpi!MPIR_Init_thread+0x0000025f<BR>0x10056883:
nmpi!PMPI_Init+0x00000053<BR>0x0040132a:
imb!main+0x0000002a<BR>--------------------------------------<BR>Handle =
0x00000328 - OPEN<BR>Thread ID = 0x00000c54, Process ID =
0x00000c50</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>0x71b22e43:
MSWSOCK!SockSocket+0x000003b0<BR>0x71b23008:
MSWSOCK!WSPSocket+0x00000126<BR>0x71c02e5d:
WS2_32!WSASocketW+0x000000ce<BR>0x71c12447:
WS2_32!WSASocketA+0x00000057<BR>0x10174d95:
nmpi!easy_create+0x00000035<BR>0x101747cc:
nmpi!MPIDU_Sock_post_connect+0x0000011c<BR>0x100d04b1:
nmpi!uPMI_ConnectToHost+0x00000041<BR>0x100cfc8a:
nmpi!iPMI_Init+0x0000049a</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Finaly, the call before the exception, on
easy_create:</FONT></DIV>
<DIV><FONT face=Arial size=2>0:000> ub 0x10174f88<BR>nmpi!easy_create+0x20e
<BR>10174f6e 8b55dc
mov edx,dword ptr [ebp-24h]<BR>10174f71
52
push edx<BR>10174f72
8bfc
mov edi,esp<BR>10174f74 ff15989a2810
call dword ptr
[nmpi!_imp__GetCurrentProcess<BR>(10289a98)]<BR>10174f7a
3bfc
cmp edi,esp<BR>10174f7c
e80f0dfaff call
nmpi!_RTC_CheckEsp (10115c90)<BR>10174f81
50
push eax<BR>10174f82 ff15949a2810
call dword ptr [nmpi!_imp__DuplicateHandle]</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Best regards,</FONT></DIV>
<DIV><FONT face=Arial size=2> Calin</FONT></DIV>
<DIV style="FONT: 10pt Tahoma">
<DIV><FONT face=Arial></FONT><BR></DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=jayesh@mcs.anl.gov
href="mailto:jayesh@mcs.anl.gov">Jayesh Krishna</A> </DIV>
<DIV><B>Sent:</B> Friday, March 28, 2008 4:17 PM</DIV>
<DIV><B>To:</B> <A title=calin@dolphinics.no
href="mailto:calin@dolphinics.no">'Calin Iaru'</A> </DIV>
<DIV><B>Cc:</B> <A title=mpich-discuss@mcs.anl.gov
href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</A> </DIV>
<DIV><B>Subject:</B> RE: [mpich-discuss] DuplicateHandle on
easy_create</DIV></DIV></DIV>
<DIV><FONT face=Arial size=2></FONT><BR></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=132031215-28032008>Hi,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=132031215-28032008> If you are referring to the use of
DuplicateHandle() in sock.c (src/mpid/common/sock/iocp/sock.c : easy_create()),
it is to prevent child processes from inheriting the socket (if you would like
to duplicate the handle to be used by another process as you mentioned one
should use WSADuplicateSocket()).</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=132031215-28032008> Are you getting any messages from your App
verifier ?</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=132031215-28032008><FONT face=Arial color=#0000ff
size=2>Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=132031215-28032008><FONT face=Arial color=#0000ff
size=2>Jayesh</FONT></SPAN></DIV>
<DIV><SPAN class=132031215-28032008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV>
<HR tabIndex=-1>
</DIV>
<DIV><FONT face=Tahoma size=2><B>From:</B> <A
href="mailto:owner-mpich-discuss@mcs.anl.gov">owner-mpich-discuss@mcs.anl.gov</A>
[mailto:owner-mpich-discuss@mcs.anl.gov] <B>On Behalf Of </B>Calin
Iaru<BR><B>Sent:</B> Friday, March 28, 2008 9:35 AM<BR><B>To:</B>
mpich-discuss@mcs.anl.gov<BR><B>Subject:</B> [mpich-discuss] DuplicateHandle on
easy_create<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><FONT face=Arial size=2>A socket object should not be duplicated using
DuplicateHandle. For reference, see:</FONT></DIV>
<DIV><FONT face=Arial size=2><A
href="http://msdn2.microsoft.com/en-us/library/ms724251(vs.85).aspx">http://msdn2.microsoft.com/en-us/library/ms724251(vs.85).aspx</A></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The problem is that if an application runs under
the control of Application Verifier, the exception may be reported and it will
require expert skills to trace the cause - use !htrace from WinDbg. Without
AppVer, no exception is raised.</FONT></DIV></BODY></HTML>