<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri" size="2"><span style="font-size:11pt;">
<div>MPI_Developers,</div>
<div> </div>
<div>It seems that when a program using mpich uses MPI-IO, it try first to open</div>
<div>a hint file specified in the ROMIO_HINTS environment variable (or</div>
<div>"/etc/romio-hints" if it is undefined) and then try to read it. The problem</div>
<div>is that it will try to read from it with the file descriptor returned by</div>
<div>open() even if the open() failed and returned a -1 (ex: file not found).</div>
<div>When this happens read() also fails and also return -1.</div>
<div> </div>
<div>The problem is when the program is run under valgrind (with the valgrind</div>
<div>friendly ch3:sock device), valgrind notice that an invalid file descriptor</div>
<div>was passed to read() and complain with a warning:</div>
<div> </div>
<div>==113473== Memcheck, a memory error detector</div>
<div>==113473== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.</div>
<div>==113473== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info</div>
<div>==113473== Command: ... </div>
<div>==113473== Parent PID: 48694</div>
<div>==113473== </div>
<div>==113473== Warning: invalid file descriptor -1 in syscall read()</div>
<div>==113473== </div>
<div>==113473== HEAP SUMMARY:</div>
<div>==113473== in use at exit: 0 bytes in 0 blocks</div>
<div>==113473== total heap usage: 4,420 allocs, 4,209 frees, 72,241,561 bytes allocated</div>
<div>==113473== </div>
<div>==113473== All heap blocks were freed -- no leaks are possible</div>
<div>==113473== </div>
<div>==113473== For counts of detected and suppressed errors, rerun with: -v</div>
<div>==113473== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)</div>
<div> </div>
<div>The problem is that no matter how clean is the program, this warning will</div>
<div>appear in its valgrind report. A developer may think that his own code is</div>
<div>problematic and start investigating...</div>
<div> </div>
<div>The solution is of course not trying to read the file if the file descriptor</div>
<div>is invalid. This could be done simply as follow (mpich 3.2.1):</div>
<div> </div>
<div>--- mpich-3.2.1/src/mpi/romio/adio/common/system_hints.c</div>
<div>+++ mpich-3.2.1-patch/src/mpi/romio/adio/common/system_hints.c</div>
<div>@@ -98,7 +98,7 @@</div>
<div> buffer = (char *)ADIOI_Calloc(HINTFILE_MAX_SIZE, sizeof (char));</div>
<div> </div>
<div> if (rank == 0) {</div>
<div>- ret = read(fd, buffer, HINTFILE_MAX_SIZE);</div>
<div>+ ret = (fd >= 0) ? read(fd, buffer, HINTFILE_MAX_SIZE) : -1;</div>
<div> /* any error: bad/nonexistent fd, no perms, anything: set up a null</div>
<div> * buffer and the subsequent string parsing will quit immediately */</div>
<div> if (ret == -1)</div>
<div> </div>
<div>Could you consider applying this patch (or an equivalent one)</div>
<div>to mpich ? It would be much appreciated.</div>
<div> </div>
<div>Thanks in advance,</div>
<div> </div>
<div>Martin Audet</div>
<div> </div>
</span></font>
</body>
</html>