Issue with std::call_once in PPC64 platform

Hi all,

I observe that r220932 (Removing the static initializer in ManagedStatic.cpp by using llvm_call_once to initialize the ManagedStatic mutex.) is causing tablegen to segfault in PPC platforms during static initialization. The crash happens while calling std::call_once introduced by this patch in the wrapper used in getManagedStaticMutex.

I understand this call is buggy for some platforms (or probably some oldish libstdc++ versions). Is this a known issue? Should we guard LLVM_DEFINE_ONCE_FLAG definition with platform specific macros to avoid the crash, at least for the moment?

Thanks!
Samuel

The MSVC STL has a similar problem, and call_once isn’t available in mingw64-win32. We have some hand-rolled double checked locking that you can probably use to workaround it.

That said, in the long term I would like to be able to rely on standard C++11 constructs.

Hi Samuel,

I haven't encountered this problem. What gcc/libstdc++ are you using?
BE or LE?

Copying Adhemerval in case he has heard of any related issues.

Thanks,
Bill

Hi Bill,

You can find the same issue in the buildbot:

http://lab.llvm.org:8011/builders/clang-ppc64-elf-linux2/builds/16444/steps/compile.llvm.stage2/logs/stdio

It is failing for me both in BE (gcc 4.8.2) and LE(4.9.1). I am compiling with clang 3.5, but those are the gcc toolchains I am using.

What do you think is the best way to fix this?

Thanks!
Samuel

Hi Samuel,

I haven't encountered this problem. What gcc/libstdc++ are you using?
BE or LE?

Never mind! We see this, but only when building for self-host. The
PPC64 clang self-host buildbot has been failing with problem as well.

It would be good to have a fix for this issue, however temporary.

Thanks,
Bill

Hi Bill,

You can find the same issue in the buildbot:

http://lab.llvm.org:8011/builders/clang-ppc64-elf-linux2/builds/16444/steps/compile.llvm.stage2/logs/stdio

It is failing for me both in BE (gcc 4.8.2) and LE(4.9.1). I am
compiling with clang 3.5, but those are the gcc toolchains I am using.

What do you think is the best way to fix this?

I don't know what the best fix is, but clearly a fix or revert is needed
since the patch is breaking some platforms.

Thanks,
Bill

Ok, I’ll put a patch together to fix this later today. I’ll probably do what Reid was suggesting and use what is already in there for Windows.

Thanks,
Samuel

Ok, I'll put a patch together to fix this later today. I'll probably
do what Reid was suggesting and use what is already in there for
Windows.

Hm, better hold off on that. Ulrich Weigand has noted that there is
invalid code generation occurring around a TLS call. Looks like is is
probably a PPC back end problem at the moment.

Thanks,
Bill

Adding Jiangning Liu to the thread.

Jiangning reported a similar issue on the llvm-commits list on Debian aarch64.

In general it sounds like std::call_once may not really be bug free.

Jiangning, can you please provide your gcc/libstdc++ version?

Thanks,
-Chris

The versions I’m using right now are

  • gcc: (Debian/Linaro 4.9.1-14) 4.9.1
  • libstdc++: libstdc++.so.6.0.20

Thanks,
-Jiangning

It seems the crash of llvm/clang build on aarch64 Debian has been fixed by r220941.

Thanks,
-Jiangning

From: "Jiangning Liu" <liujiangning1@gmail.com>
To: "Chris Bieneman" <beanz@apple.com>
Cc: "Bill Schmidt" <wschmidt@linux.vnet.ibm.com>, "Samuel F Antao" <sfantao@us.ibm.com>, azanella@linux.vnet.ibm.com,
"Hal Finkel" <hfinkel@anl.gov>, "LLVM Dev" <llvmdev@cs.uiuc.edu>, "ulrich weigand" <ulrich.weigand@de.ibm.com>
Sent: Tuesday, November 4, 2014 6:56:07 PM
Subject: Re: Issue with std::call_once in PPC64 platform

It seems the crash of llvm/clang build on aarch64 Debian has been
fixed by r220941.

That's scary. Is there any actual code-generation change from that commit?

-Hal

Sorry, That was my mistake. It just showed my build can pass after reverting 220932.

Can this be reverted ASAP? This is actually blocking clang/llvm self-build on aarch64 target.

The error message is like,

[ 20%] Building arm_neon.h…
/bin/sh: line 1: 28055 Segmentation fault …/…/…/…/bin/clang-tblgen -gen-arm-neon -I /work/slave/performance-daily/build/tools/clang/lib/Headers -I /work/slave/performance-daily/build/lib/Target -I /work/slave/performance-daily/build/include /work/slave/performance-daily/build/tools/clang/include/clang/Basic/arm_neon.td -o /work/slave/performance-daily/build/build/tools/clang/lib/Headers/arm_neon.h.tmp

Thanks,
-Jiangning

Sorry, I reverted commit 220932 by 221331.

I have to do this because it is a showstopper failure, and all aarch64 target build are being blocked in the past 4 days.

Thanks,
-Jiangning