[LLVMdev] unexpectedly loop hanging

Alexandru Ionut Diaconescu alexandruionutdiaconescu at gmail.com
Thu May 30 04:31:26 PDT 2013


As an update, here is the current piece of code:

Inside a loop iterating over each basic block :

*std::vector<Value*> values;
values.resize(cnt);

//std::vector<Value*> values(sizeof(Value*)*cnt);
//SmallVector<Value*,cnt> values;

if(is)
{
     LLVMContext& C = is->getContext();
     errs()<<"\ni: \n";

     for(i=0;i<cnt;i++){
          values[i]=ConstantInt::getSigned(Type::getInt64Ty(C),myArray[i]);
          errs()<<" "<<myArray[i];
      }

      is->setMetadata("path",MDNode::get(C,values));
      errs()<<"\nmodif instr  "<<*is<<"\n";

      if( (is->getMetadata("path")) ){
        for(i=0;i<cnt;i++){
          if(is->getMetadata("path")->getOperand(i)) {
            errs()<<"\nget isntr
"<<*(is->getMetadata("path")->getOperand(i))<<"\n";
          }
        }
      }
}
values.clear();*


I receive a memory corruption error at some basic blocks. Here are the
debug outputs:

1. opt - *opt: malloc.c:3801: _int_malloc: Assertion `(unsigned long)(size)
>= (unsigned long)(nb)' failed.*

2. gdb -
*Program received signal SIGABRT, Aborted.
0xb7fdd424 in __kernel_vsyscall ()*

3. valgrind - it executes all the code and at the problematic loop
iteration I have :

*==5134== Invalid write of size 4
==5134==    at 0x4039280: (anonymous
namespace)::Hello::runOnModule(llvm::Module&) (in
/home/alex/llvm/Release+Asserts/lib/Hello.so)
==5134==    by 0x8E33DE3: llvm::MPPassManager::runOnModule(llvm::Module&)
(in /home/alex/llvm/Release+Asserts/bin/opt)
==5134==    by 0x8E3726F: llvm::PassManagerImpl::run(llvm::Module&) (in
/home/alex/llvm/Release+Asserts/bin/opt)
==5134==    by 0x8E37385: llvm::PassManager::run(llvm::Module&) (in
/home/alex/llvm/Release+Asserts/bin/opt)
==5134==    by 0x41AE4D2: (below main) (libc-start.c:226)
==5134==  Address 0x46cfa40 is 0 bytes after a block of size 200 alloc'd
==5134==    at 0x402C454: operator new[](unsigned int) (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==5134==    by 0x4037AE0: (anonymous
namespace)::Hello::runOnModule(llvm::Module&) (in
/home/alex/llvm/Release+Asserts/lib/Hello.so)*

and repeating.

*==5230== HEAP SUMMARY:
==5230==     in use at exit: 95,110 bytes in 317 blocks
==5230==   total heap usage: 33,395 allocs, 33,078 frees, 4,484,753 bytes
allocated
==5230==
==5230== LEAK SUMMARY:
==5230==    definitely lost: 7,732 bytes in 31 blocks
==5230==    indirectly lost: 85,864 bytes in 275 blocks
==5230==      possibly lost: 0 bytes in 0 blocks
==5230==    still reachable: 1,514 bytes in 11 blocks
==5230==         suppressed: 0 bytes in 0 blocks
==5230== Rerun with --leak-check=full to see details of leaked memory
==5230==
==5230== For counts of detected and suppressed errors, rerun with: -v
==5230== ERROR SUMMARY: 16432 errors from 15 contexts (suppressed: 0 from 0)
*

I assume the main problems are:
1. I don't allocate well memory for values. Or maybe I am allocating only
for Value* pointers, not for the actual values. Maybe I don't free the mem.
2. I cannot use array instead of vector, since *
is->setMetadata("path",MDNode::get(C,values));* won't let me.

What do you think it is wrong? What should I try? I want only to attach
some integers as metadata, one integer per operand.

Thank you !



On Wed, May 29, 2013 at 10:00 AM, Alexandru Ionut Diaconescu <
alexandruionutdiaconescu at gmail.com> wrote:

> Hello Duncan,
>
> Yes, I built it with assertions and I have also debug info.
>
>
> On Tue, May 28, 2013 at 5:47 PM, Duncan Sands <baldrick at free.fr> wrote:
>
>> Hi Alexandru, did you build LLVM with assertions enabled?  If not then you
>> should do.
>>
>> Ciao, Duncan.
>>
>> ______________________________**_________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>
>>
>
>
>
> --
> Best regards,
> Alexandru Ionut Diaconescu
>



-- 
Best regards,
Alexandru Ionut Diaconescu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130530/bdb723c5/attachment.html>


More information about the llvm-dev mailing list