<div dir="ltr">Hi,<div><br></div><div>I don't know much about this issue, but this malloc error won't be solved by a change to delete[] or free. In fact, if you use the incorrect one for simple types, you may not notice it. The error you have seems to me like a memory corruption because you went out of bound and corrupted the memory somewhere, Valgrind may help you figure out what is going on.</div>
<div><br></div><div style>Cheers,</div><div style><br></div><div style>Matthieu</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/5/28 Alexandru Ionut Diaconescu <span dir="ltr"><<a href="mailto:alexandruionutdiaconescu@gmail.com" target="_blank">alexandruionutdiaconescu@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>As an update, it is a memory problem which I don't know how to fix.<br><br></div>I tried to skip the problematic piece of code when in the case when the loop hangs. So I did something like :<br>

<br>          if( instr )<br>          {<br>            LLVMContext& C = instr->getContext();<div class="im"><br><br>              Value* values[cnt];<br>              errs()<<"\ngy: \n";<br><br></div>
          if(!(desters==7)){    // this is the condition I put to skip the case when it hanged<div class="im"><br>
<br>              for(int gy=0;gy<cnt;gy++){<br></div>                values[gy]=ConstantInt::getSigned(Type::getInt64Ty(C),cebag[gy]);<br>                errs()<<" "<<gy;<br>              }<br><br>
             SmallVector<Value*, 100> bla;<div class="im"><br>
             for(int gy=0;gy<cnt;gy++){<br></div>              bla.push_back(values[gy]);<br>              }<br><br>            instr->setMetadata("path",MDNode::get(C,bla));<br><br><br>                if( (instr->getMetadata("path")) ){  <br>
<div class="im">
                  for(int gy=0;gy<cnt;gy++){ <br></div>                      if(instr->getMetadata("path")->getOperand(gy)) { <br>                    errs()<<"\n  "<<*(is->getMetadata("path")->getOperand(gy))<<"\n";<br>

<br>                  }<br>                 }<br>                }<br><br></div>            } // closing bracket for the extra condition that I put<br><div><div>            <br>          }<br><br><br></div><div>From the terminal output, I see that the problematic case is skipped, but then it was printed:<br>

<br>---------------------------PROCEED TO NEXT BB------------------------------------<br>opt: malloc.c:3790: _int_malloc: Assertion `(unsigned long)(size) >= (unsigned long)(nb)' failed.<br><br></div><div>So I thought that the problem is regarding memory freeing. I was trying to free the memory for arrays like values or bla, using delete [] name and even free(), but I am getting segfault.<br>

<br></div><div>I think it is some basic stuff that I miss.<div class="im"><br><br>Thank you for any suggestion !<br></div></div><div><br></div></div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">
On Tue, May 28, 2013 at 10:02 AM, Alexandru Ionut Diaconescu <span dir="ltr"><<a href="mailto:alexandruionutdiaconescu@gmail.com" target="_blank">alexandruionutdiaconescu@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hello everyone,</div><div><div><br>I was able to get all the execution 
paths between 2 points (basic blocks) in my program (with the condition to traverse a loop only once). I mapped all the 
basic blocks to integers and created a correspondent directed graph.<br>
<br></div>I was able to get all the paths (a path is represented by an integer identifier). For my target program I have 72 paths, but 
the program hangs unexpectedly at a for loop when I am adding metadata 
(which is containing the paths). This part of code was working perfectly before of changing the algorithm to traverse the loop only once. However, the traverse algorithm should be totally independent to the part of the code where I add metadata. The single influence that I see is that I have to add more metadata operands to instructions. I mention that for each metadata operand I add a path = an integer identifier. When this was working, I used to add up to 17 metadata operands, now I have up to 72.</div>


<div><br></div>How do I add metadata: Inside a<b> </b>loop iterating through basic blocks, for each basic block I take a particular instruction on which I want to attach the metadata (a path = an integer identifier). I do like this :<br>



<br>if( instruc )<br>{<br>LLVMContext& C = instruc->getContext();<br><br>             Value* values[cnt]; <br>             errs()<<"\ngy: \n";<br>              for(int gy=0;gy<cnt;gy++)<div>              {<div>



                values[gy]=ConstantInt::getSigned(Type::getInt64Ty(C),myarray[gy]);<br>                errs()<<" "<<gy;<br>               }</div><div>}</div><div><br></div><div>1. I checked before this part of the code the values of myarray and they are good</div>


<div>2. It works well for the first 6 instructions (the maximum number of metadata operands they need is 70), but when I get to the 7th instruction to add metadata (with 72 operands), I hangs inside the for loop from above, having :</div>


<div><br></div><div>gy:</div><div> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16</div><div><br></div><div>and it hangs. Before this part of the code I print myarray[gy] and it it prints all the values from 0 to 71 (the basic block is contained in all possible execution paths).</div>


<div><br></div><div>What do you think is the problem? Some memory allocation (I have sufficient allocated), maybe I cannot add so many metadata operands? </div><div><br></div><div>Thank you for any suggestion !<br><br>
<br><br><div><div><br><br></div></div></div></div></div>
</blockquote></div><br><br clear="all"><br></div></div><span class="HOEnZb"><font color="#888888">-- <br><font style="color:rgb(153,153,153)">Best regards,</font><br style="color:rgb(153,153,153)"><font style="color:rgb(153,153,153)">Alexandru Ionut Diaconescu</font><br>


</font></span></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Information System Engineer, Ph.D.<br>Blog: <a href="http://matt.eifelle.com" target="_blank">http://matt.eifelle.com</a><span style="padding-right:16px;width:16px;height:16px"></span><span style="padding-right:16px;width:16px;height:16px"></span><br>
LinkedIn: <a href="http://www.linkedin.com/in/matthieubrucher" target="_blank">http://www.linkedin.com/in/matthieubrucher</a><span style="padding-right:16px;width:16px;height:16px"></span><br>Music band: <a href="http://liliejay.com/" target="_blank">http://liliejay.com/</a><span style="padding-right:16px;width:16px;height:16px"></span><br>
<span style="padding-right:16px;width:16px;height:16px"></span>
</div>