Skip to content

operator delete[] leads to "index out of range" crash when using Microsoft ABI #12705

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

Closed
timurrrr opened this issue Mar 23, 2012 · 7 comments
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla c++

Comments

@timurrrr
Copy link
Contributor

Bugzilla Link 12333
Resolution FIXED
Resolved on Mar 19, 2014 03:27
Version trunk
OS Windows NT
Blocks llvm/llvm-bugzilla-archive#12477
CC @DougGregor,@ramosian-glider,@rjmccall

Extended Description

$ clang++.exe
clang version 3.1 (trunk 152788)
Target: i686-pc-win32
Thread model: posix

$ more operator_delete_array.cpp
int main() {
char *ptr = 0;
delete [] ptr;
}

$ clang++.exe -Xclang -cxx-abi -Xclang microsoft operator_delete_array.cpp
Assertion failed: Idx < getNumArgs() && "Argument index out of range!", file clang\include\clang/Basic/Diagnostic.h, line 994
clang++: error: clang frontend command failed with exit code 3 (use -v to see invocation)

@timurrrr
Copy link
Contributor Author

assigned to @timurrrr

@ramosian-glider
Copy link
Contributor

$ build/Release+Asserts/bin/clang++ -Xclang -cxx-abi -Xclang microsoft del.cpp
Assertion failed: (Idx < getNumArgs() && "Argument index out of range!"), function getArgKind, file /Users/glider/src/asan/asan-llvm-trunk/llvm/tools/clang/lib/Basic/../../include/clang/Basic/Diagnostic.h, line 994.
0 clang 0x000000010169e172 PrintStackTrace(void*) + 34
1 clang 0x000000010169e6f9 SignalHandler(int) + 745
2 libSystem.B.dylib 0x00007fff818b61ba _sigtramp + 26
3 libSystem.B.dylib 000000000000000000 _sigtramp + 2121571936
4 clang 0x00000001000492e6 abort + 22
5 clang 0x0000000100049338 __assert_rtn + 56
6 clang 0x0000000100b14c31 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl&) const + 3083
7 clang 0x00000001000add13 clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) + 111
8 clang 0x0000000100b1906f clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const + 463
9 clang 0x0000000100b1561e clang::DiagnosticsEngine::EmitCurrentDiagnostic() + 22
10 clang 0x00000001001bcac2 ErrorUnsupportedABI(clang::CodeGen::CodeGenFunction&, llvm::StringRef) + 194
11 clang 0x00000001001bc9ad clang::CodeGen::CGCXXABI::ReadArrayCookie(clang::CodeGen::CodeGenFunction&, llvm::Value*, clang::CXXDeleteExpr const*, clang::QualType, llvm::Value*&, llvm::Value*&, clang::CharUnits&) + 33
12 clang 0x000000010020f55c clang::CodeGen::CodeGenFunction::EmitCXXDeleteExpr(clang::CXXDeleteExpr const*) + 1096
13 clang 0x0000000100224f4d clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) + 13085
14 clang 0x000000010021d06f clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 95
15 clang 0x00000001001f7748 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) + 60
16 clang 0x000000010020052d clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) + 45
17 clang 0x00000001002777d3 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 419
18 clang 0x000000010027a21c clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) + 224
19 clang 0x0000000100277b1a clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*) + 146
20 clang 0x0000000100277659 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 41
21 clang 0x00000001002857d7 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 847
22 clang 0x000000010029d280 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl) + 2348
23 clang 0x000000010029ede2 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl) + 408
24 clang 0x000000010029f3af clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 1353
25 clang 0x000000010029f6d3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 203
26 clang 0x00000001002aa51f (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) + 123
27 clang 0x0000000100280e33 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) + 167
28 clang 0x00000001002b5c42 clang::ParseAST(clang::Sema&, bool) + 290
29 clang 0x000000010027fa47 clang::CodeGenAction::ExecuteAction() + 1163
30 clang 0x000000010006ad38 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 850
31 clang 0x0000000100053422 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2434
32 clang 0x000000010004ccb1 cc1_main(char const**, char const**, char const*, void*) + 2977
33 clang 0x000000010005036d main + 621
34 clang 0x000000010004c0fc start + 52

tools/clang/lib/CodeGen/MicrosoftCXXABI.cpp simply does not implement ReadArrayCookie().

@timurrrr
Copy link
Contributor Author

Good catch, Alexander!

I'll add this method with llvm_unreachable then.

@timurrrr
Copy link
Contributor Author

timurrrr commented Apr 4, 2012

In r153990 I've overridden ReadArrayCookie() to at least produce a readable error text.

@timurrrr
Copy link
Contributor Author

I think I came up with a piece of code that deals with cookies in Microsoft ABI,
but I can't test it thoroughly due to bug 12574.
Will work on that first.

@rjmccall
Copy link
Contributor

rjmccall commented May 1, 2012

I believe this should be fixed in r155886; re-open this if I'm mistaken.

@timurrrr
Copy link
Contributor Author

mentioned in issue llvm/llvm-bugzilla-archive#12477

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
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 c++
Projects
None yet
Development

No branches or pull requests

3 participants