[llvm-bugs] [Bug 45876] New: wasm: __cxa_atexit called with wrong signature function for global reference temporaries

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 11 09:44:31 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45876

            Bug ID: 45876
           Summary: wasm: __cxa_atexit called with wrong signature
                    function for global reference temporaries
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: WebAssembly
          Assignee: unassignedbugs at nondot.org
          Reporter: vladimir at pobox.com
                CC: dan433584 at gmail.com, llvm-bugs at lists.llvm.org

The following snippet (from Dan Gohman):

struct B { B(); ~B(); };
namespace test {
  const B b1 = B();
  const B &b2 = B();
}

shows the problem -- the global_var_init that's generated to initialize the b2
reference is created with a call to __cxa_atexit that directly passes the
destructor.  A dtor's function signature doesn't match what __cxa_atexit needs,
so there's a signature mismatch at execution time (at app exit).

For normal global destructors, there's a path that explicitly checks for
whether cxa_atexit can be called directly with a destructor, and if not,
generates a helper:
https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGDeclCXX.cpp#L106

But the reference temporary destructor goes through here (I think), which
doesn't check if the platform allows destructors to be passed to cxa_atexit:
https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGExpr.cpp#L347

Long-form discussion here:
https://bytecodealliance.zulipchat.com/#narrow/stream/206238-general/topic/__funcs_on_exit.20indirect.20call.20type.20mismatch.20with.20wasi-sdk

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200511/2cf120ef/attachment.html>


More information about the llvm-bugs mailing list