Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llc reads freed memory when run on 2006-11-30-NoCompileUnit.cpp #2056

Closed
llvmbot opened this issue Sep 19, 2007 · 9 comments
Closed

llc reads freed memory when run on 2006-11-30-NoCompileUnit.cpp #2056

llvmbot opened this issue Sep 19, 2007 · 9 comments
Labels
bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 19, 2007

Bugzilla Link 1684
Resolution FIXED
Resolved on Sep 23, 2007 02:35
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @asl

Extended Description

Running test/C++Frontend/2006-11-30-NoCompileUnit.cpp under valgrind
shows it reading freed memory in llvm::DIEBlock::BestForm.

To reproduce, run
llvm-gcc -S -O0 -emit-llvm -g 2006-11-30-NoCompileUnit.cpp -o - | llvm-as | valgrind --tool=memcheck llc --disable-fp-elim -f -o NoCompileUnit.s

@asl
Copy link
Collaborator

asl commented Sep 19, 2007

Mine

@asl
Copy link
Collaborator

asl commented Sep 19, 2007

Erm, wanted 1685 :)

@lattner
Copy link
Collaborator

lattner commented Sep 21, 2007

Dale, can you take a look at this one?

Duncan, can you please attach the valgrind dump?

Thanks,

-Chris

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 21, 2007

Full backtrace:

Invalid read of size 4
at 0x868433F: llvm::DIEBlock::BestForm() const (DwarfWriter.cpp:622)
by 0x86955E2: llvm::DwarfDebug::AddBlock(llvm::DIE*, unsigned, unsigned, llvm::DIEBlock*) (DwarfWriter.cpp:1307)
by 0x8698227: llvm::DwarfDebug::ConstructType(llvm::DIE&, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1565)
by 0x869708B: llvm::DwarfDebug::AddType(llvm::DIE*, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1417)
by 0x8697A2E: llvm::DwarfDebug::ConstructType(llvm::DIE&, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1447)
by 0x869708B: llvm::DwarfDebug::AddType(llvm::DIE*, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1417)
by 0x8697A2E: llvm::DwarfDebug::ConstructType(llvm::DIE&, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1447)
by 0x869708B: llvm::DwarfDebug::AddType(llvm::DIE*, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1417)
by 0x86986F5: llvm::DwarfDebug::ConstructType(llvm::DIE&, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1643)
by 0x869708B: llvm::DwarfDebug::AddType(llvm::DIE*, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1417)
by 0x8697A2E: llvm::DwarfDebug::ConstructType(llvm::DIE&, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1447)
by 0x869708B: llvm::DwarfDebug::AddType(llvm::DIE*, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1417)
Address 0x438b960 is 80 bytes inside a block of size 84 free'd
at 0x4022166: operator delete(void*) (vg_replace_malloc.c:336)
by 0x868C3EF: llvm::DIEBlock::~DIEBlock() (DwarfWriter.cpp:609)
by 0x86955CE: llvm::DwarfDebug::AddBlock(llvm::DIE*, unsigned, unsigned, llvm::DIEBlock*) (DwarfWriter.cpp:1304)
by 0x8698227: llvm::DwarfDebug::ConstructType(llvm::DIE&, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1565)
by 0x869708B: llvm::DwarfDebug::AddType(llvm::DIE*, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1417)
by 0x8697A2E: llvm::DwarfDebug::ConstructType(llvm::DIE&, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1447)
by 0x869708B: llvm::DwarfDebug::AddType(llvm::DIE*, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1417)
by 0x8697A2E: llvm::DwarfDebug::ConstructType(llvm::DIE&, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1447)
by 0x869708B: llvm::DwarfDebug::AddType(llvm::DIE*, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1417)
by 0x86986F5: llvm::DwarfDebug::ConstructType(llvm::DIE&, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1643)
by 0x869708B: llvm::DwarfDebug::AddType(llvm::DIE*, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1417)
by 0x8697A2E: llvm::DwarfDebug::ConstructType(llvm::DIE&, llvm::TypeDesc*, llvm::CompileUnit*) (DwarfWriter.cpp:1447)

@lattner
Copy link
Collaborator

lattner commented Sep 21, 2007

The problem is obvious:
if (!Value) {
Value = Block;
ValuesSet.InsertNode(Value, Where);
Values.push_back(Value);
} else {
delete Block;
}

Die->AddValue(Attribute, Block->BestForm(), Value);

If Value is true, it deletes Block then dereferences it.

@lattner
Copy link
Collaborator

lattner commented Sep 21, 2007

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 23, 2007

Chris,

Can we close this if it's fixed? ;-)

--Owen

@nlewycky
Copy link
Contributor

Chris, did you want to close this bug? I can't reproduce it with the fix applied, though I haven't tried it without the fix.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 23, 2007

I can confirm that this bug is now fixed.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
kitano-metro pushed a commit to RIKEN-RCCS/llvm-project that referenced this issue Mar 20, 2023
kitano-metro pushed a commit to RIKEN-RCCS/llvm-project that referenced this issue Mar 20, 2023
refs llvm#2056 COPY生成でliveinを意識するように変更

See merge request a64fx-swpl/llvm-project!107
vfdff added a commit to vfdff/llvm-project that referenced this issue Dec 5, 2023
When all the large const offsets masked with the same value from bit-12 to bit-23.
Fold
  add     x8, x0, llvm#2031, lsl llvm#12
  add     x8, x8, llvm#960
  ldr     x9, [x8, x8]
  ldr     x8, [x8, llvm#2056]

into
  add     x8, x0, llvm#2031, lsl llvm#12
  ldr     x9, [x8, llvm#960]
  ldr     x8, [x8, llvm#3016]
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

4 participants