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

assertion failure converting lambda returning trivial_abi struct to function pointer #42306

Closed
comex opened this issue Aug 12, 2019 · 7 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla c++

Comments

@comex
Copy link
Contributor

comex commented Aug 12, 2019

Bugzilla Link 42961
Resolution FIXED
Resolved on Jun 22, 2021 21:16
Version trunk
OS All
Blocks #48661
CC @aeubanks,@DougGregor,@DimitryAndric,@zygoloid,@tstellar
Fixed by commit(s) c8227f0 6c57bab

Extended Description

I think the fix may be to just change the assert in EmitAggregateCopy, as memcpying a trivial_abi return value should work.

Test case:


struct A {
A(A &);
A &operator=(const A &);
} attribute((trivial_abi));
A (*f)() = -> A {};


$ clang -cc1 -triple x86_64-apple-macosx10.14.0 -S test.cpp

Assertion failed: ((Record->hasTrivialCopyConstructor() || Record->hasTrivialCopyAssignment() || Record->hasTrivialMoveConstructor() || Record->hasTrivialMoveAssignment() || Record->isUnion()) && "Trying to aggregate-copy a type without a trivial copy/move " "constructor or assignment operator"), function EmitAggregateCopy, file /usr/src/llvm/clang/lib/CodeGen/CGExprAgg.cpp, line 1928.

(lldb) bt

  • thread #​1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    • frame #​0: 0x00007fff77cad2a6 libsystem_kernel.dylib__pthread_kill + 10 frame #​1: 0x00007fff77d68bf1 libsystem_pthread.dylibpthread_kill + 284
      frame #​2: 0x00007fff77c176a6 libsystem_c.dylibabort + 127 frame #​3: 0x00007fff77be020d libsystem_c.dylib__assert_rtn + 324
      frame #​4: 0x000000010bdfc13b libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::EmitAggregateCopy(this=0x00007ffeefbf84a8, Dest=LValue @ 0x00007ffeefbf76b0, Src=LValue @ 0x00007ffeefbf7710, Ty=QualType @ 0x00007ffeefbf7698, MayOverlap=DoesNotOverlap, isVolatile=false) at CGExprAgg.cpp:1922:7 frame #​5: 0x000000010c03dd03 libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::EmitReturnOfRValue(this=0x00007ffeefbf84a8, RV=RValue @ 0x00007ffeefbf7a40, Ty=QualType @ 0x00007ffeefbf7a38) at CGStmt.cpp:1031:5
      frame #​6: 0x000000010bcca97a libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::EmitForwardingCallToLambda(this=0x00007ffeefbf84a8, callOperator=0x0000000124057a20, callArgs=0x00007ffeefbf7cc8) at CGClass.cpp:2855:5 frame #​7: 0x000000010bccb05d libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::EmitLambdaDelegatingInvokeBody(this=0x00007ffeefbf84a8, MD=0x0000000124057cc8) at CGClass.cpp:2917:3
      frame #​8: 0x000000010bccb1db libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::EmitLambdaStaticInvokeBody(this=0x00007ffeefbf84a8, MD=0x0000000124057cc8) at CGClass.cpp:2928:3 frame #​9: 0x000000010c0d9179 libclangCodeGen.dylibclang::CodeGen::CodeGenFunction::GenerateCode(this=0x00007ffeefbf84a8, GD=GlobalDecl @ 0x00007ffeefbf83b0, Fn=0x0000000122404aa8, FnInfo=0x00000001224037c0) at CodeGenFunction.cpp:1193:5
@comex
Copy link
Contributor Author

comex commented Aug 12, 2019

assigned to @rnk

@aeubanks
Copy link
Contributor

aeubanks commented Mar 3, 2021

We're also now seeing this in Chromium as https://crbug.com/1183556.

@DimitryAndric
Copy link
Collaborator

This was fixed by Arthur in c8227f06b335 . Can we still merge this to 12.0.1, as it is a quite trivial fix? It would be nice to build Chromium without asserting. :)

@tstellar
Copy link
Collaborator

Hi Reid,

What is your opinion on backporting this?

@rnk
Copy link
Collaborator

rnk commented Jun 22, 2021

Hi Reid,

What is your opinion on backporting this?

It's 100% safe to backport, it only changes an assertion condition.

@tstellar
Copy link
Collaborator

Merged: 6c57bab

@tstellar
Copy link
Collaborator

mentioned in issue #48661

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 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

5 participants