<div>I don't have any long options. For example. I takes a look at following code<br>==12208== Conditional jump or move depends on uninitialised value(s)<br>==12208==&nbsp;&nbsp;&nbsp; at 0x171A9FA: PetscStrlen (str.c:149)<br>==12208==&nbsp;&nbsp;&nbsp; by 0x16EFF89: PetscOptionsHasName (options.c:1242)<br>==12208==&nbsp;&nbsp;&nbsp; by 0x141AA4A: main (main.cc:101)<br>==12208==<br>In the line 101 of main.cc I just call PetscOptionsHasName to check -p command line argument.<br>And the -p argument don't have parameter.<br>&nbsp; // performace log flag<br>&nbsp; PetscBool&nbsp;&nbsp;&nbsp;&nbsp; log_flg;<br>&nbsp; PetscOptionsHasName(PETSC_NULL,"-p", &amp;log_flg);<br>&nbsp; if(!log_flg)<br>&nbsp;&nbsp;&nbsp; perflog.disable_logging(); <br><br><br>I checked petsc source file options.c<br>In the source file options.c line 1098<br>static PetscErrorCode PetscOptionsFindPair_Private(const char pre[],const char name[],char *value[],PetscBool&nbsp; *flg) <br><br>the tmp buffer has a fixed size of 256. the strncpy function has a max number of 256.<br>&nbsp; /* append prefix to name */<br>&nbsp; if (pre) {<br>&nbsp;&nbsp;&nbsp; if (pre[0] == '-') SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Prefix should not begin with a -");<br>&nbsp;&nbsp;&nbsp; ierr = PetscStrncpy(tmp,pre,256);CHKERRQ(ierr);<br>&nbsp;&nbsp;&nbsp; ierr = PetscStrlen(tmp,&amp;len);CHKERRQ(ierr);<br>&nbsp;&nbsp;&nbsp; ierr = PetscStrncat(tmp,name+1,256-len-1);CHKERRQ(ierr);<br>&nbsp; } else {<br>&nbsp;&nbsp;&nbsp; ierr = PetscStrncpy(tmp,name+1,256);CHKERRQ(ierr);<br>&nbsp; }<br>This should OK if name string has a length less than 256. The length of -p option is only 2. <br>However, valgrind reported here has uninitialised value.<br><br><br>I try to init both tmp (line 1103) and tmp2 (line 1152) as tmp[256]={0}, tmp2[256]={0}, the valgrind complain disappeared.<br><br>I'v no idea what's wrong here. Maybe something wrong in valgrind.<br><br></div><blockquote style="padding-left:5px;margin-left:5px;border-left:#a0c6e5 2px solid;margin-right:0px"><br><br><br><div class="gmail_quote">On Sat, Dec 3, 2011 at 06:18, Gong Ding <span dir="ltr">&lt;<a href="mailto:gdiso@ustc.edu">gdiso@ustc.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 8ex;border-left:1px #ccc solid;padding-left:1ex;">
In the function of PetscOptionsFindPair_Private (options.c line 1098), there are still some code with the same problem.</blockquote></div><br><div>Are you passing a full path to the option? Or just many very long prefixes?</div>
<div><br></div><div>This absolutely needs to be fixed, but I think there are a lot of places where fixed-length temporary buffers are used for building options keys and values. I would like to know how you are triggering these overflows so that I can stand a decent chance of getting all of them.</div>
</blockquote><span ></span>