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

Compile error: "Pass 'Move heap allocations to the stack' is not initialized" #1225

Closed
avsej opened this issue Sep 16, 2016 · 18 comments
Closed

Comments

@avsej
Copy link
Contributor

avsej commented Sep 16, 2016

I've just tried to build trivial helloworld from
tutorial, and it fails to compile. I've tried the build from bintray
and manually compiled, all of the output something like this:

Building builtin ->
/home/avsej/.local/lib/pony/0.3.1-1-g8a8ee28/packages/builtin
Building . -> /home/avsej/code/pony/helloworld
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Pass 'Move heap allocations to the stack' is not initialized.
Verify if there is a pass dependency cycle.
Required Passes:
Segmentation fault (core dumped)

Backtrace:

Thread 1 (Thread 0x7f88c13f0980 (LWP 10246)):
#0  llvm::PassInfo::createPass (this=0x0) at /usr/src/debug/llvm-3.8.0.src/include/llvm/PassInfo.h:118
#1  llvm::PMTopLevelManager::schedulePass (this=0x2533828, P=0x25402f0) at /usr/src/debug/llvm-3.8.0.src/lib/IR/LegacyPassManager.cpp:669
#2  0x000000000048b9b8 in addHeapToStackPass (pmb=..., pm=...) at src/libponyc/codegen/genopt.cc:484
#3  0x00007f88bf9c84d3 in llvm::PassManagerBuilder::addExtensionsToPM (this=this@entry=0x7ffe78c8de70, ETy=ETy@entry=llvm::PassManagerBuilder::EP_Peephole, PM=...) at /usr/src/debug/llvm-3.8.0.src/lib/Transforms/IPO/PassManagerBuilder.cpp:154
#4  0x00007f88bf9c8f96 in llvm::PassManagerBuilder::populateModulePassManager (this=0x7ffe78c8de70, MPM=...) at /usr/src/debug/llvm-3.8.0.src/lib/Transforms/IPO/PassManagerBuilder.cpp:236
#5  0x000000000048bdda in optimise (c=0x7ffe78c8e0b0, pony_specific=0x1) at src/libponyc/codegen/genopt.cc:946
#6  0x000000000048c0a9 in genopt (c=0x7ffe78c8e0b0, pony_specific=0x1) at src/libponyc/codegen/genopt.cc:984
#7  0x000000000045a004 in genexe (c=0x7ffe78c8e0b0, program=0x7f88bd06ed40) at src/libponyc/codegen/genexe.c:424
#8  0x0000000000455c5f in codegen (program=0x7f88bd06ed40, opt=0x7ffe78c8e460) at src/libponyc/codegen/codegen.c:717
#9  0x0000000000425391 in generate_passes (program=0x7f88bd06ed40, options=0x7ffe78c8e460) at src/libponyc/pass/pass.c:286
#10 0x000000000040b445 in compile_package (path=0x4b59e6 ".", opt=0x7ffe78c8e460, print_program_ast=0x0, print_package_ast=0x0) at src/ponyc/main.c:245
#11 0x000000000040b867 in main (argc=0x1, argv=0x7ffe78c8e5d8) at src/ponyc/main.c:368

Although when I disable optimizations (-d) it works as expected

$ lsb_release -rid
Distributor ID: Fedora
Description:    Fedora release 24 (Twenty Four)
Release:    24
$ llvm-config --version --build-mode --host-target --assertion-mode --shared-mode --has-rtti
3.8.0
RelWithDebInfo
x86_64-unknown-linux-gnu
OFF
YES
shared
@avsej
Copy link
Contributor Author

avsej commented Sep 16, 2016

Pull docker image

docker run --rm -ti fedora:24 /bin/bash

Checkout and build

dnf groupinstall -y 'Development Tools'
# not everywhere 'which' is installed, but Makefile assumes it
dnf install -y llvm-devel gcc-c++ which zlib-devel ncurses-devel
git clone git://github.com/ponylang/ponyc.git
cd ponyc
make
build/debug/ponyc examples/helloworld

Output as above

Building builtin -> /ponyc/packages/builtin
Building . -> /ponyc/examples/helloworld
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Pass 'Move heap allocations to the stack' is not initialized.
Verify if there is a pass dependency cycle.
Required Passes:
Segmentation fault

@avsej
Copy link
Contributor Author

avsej commented Sep 19, 2016

As I noted in #1236, the problem is not reproducing on llvm-3.9

@sylvanc
Copy link
Contributor

sylvanc commented Sep 21, 2016

As @Praetonus pointed out in #1236, this looks like it could be an LLVM 3.8 bug, in combination with gcc 6.

@SeanTAllen
Copy link
Member

Could we get away, once 3.9 is in place with advising people not to use LLVM 3.8?

@Theodus
Copy link
Contributor

Theodus commented Oct 19, 2016

Does this error occur when using LLVM 3.8.1?

@SeanTAllen
Copy link
Member

In the absence of other info, we are assuming this was a llvm 3.8.0 bug. To anyone reading in the future, if you experience this with 3.8.1 or other supported LLVMs please open a new issue.

@fgrosse
Copy link

fgrosse commented Jan 30, 2017

@SeanTAllen I have this issue on llvm 3.8.1 should I actually open a new issue now?

@SeanTAllen
Copy link
Member

@fgrosse are you using gcc 6?

@SeanTAllen SeanTAllen reopened this Jan 30, 2017
@fgrosse
Copy link

fgrosse commented Jan 30, 2017

I had this issue on two different machines with llvm 3.8.1 installed on Linux Fedora 25 via the package manager dnf)

$ gcc --version
gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname -a
Linux argo 4.9.3-200.fc25.x86_64 #1 SMP Fri Jan 13 01:01:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I did now install a more recent LLVM version by building version 3.9.1 from source and was able to compile and run examples/helloworld.

@SeanTAllen
Copy link
Member

So the supposition that it is a LLVM 3.8.x and GCC 6.x issue appears to be accurate.

@LaurentTreguier
Copy link

LaurentTreguier commented Apr 25, 2017

Hello there, I just tried building ponyc 0.13.1 from source, on Fedora 25 with LLVM 3.9.1 and gcc 6.3.1, but still had this exact issue:

$ ponyc --version
0.13.1 [release]
compiled with: llvm 3.9.1 -- gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)
$ ponyc
Building builtin -> /usr/lib64/ponyc/packages/builtin
Building . -> /tmp/hello
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Pass 'Move heap allocations to the stack' is not initialized.
Verify if there is a pass dependency cycle.
Required Passes:
fish: 'ponyc' terminated by signal SIGSEGV (Erreur de frontière d'adresse)

@SeanTAllen
Copy link
Member

@avsej when you had this issue, were you using gcc 6.3.1? So far reported gcc versions are all 6.3.1. This is looking like a GCC specific issue to me.

@KaroLaunonen
Copy link
Contributor

KaroLaunonen commented May 8, 2017

Hi, I tried building from source with tags 0.13.1 and 0.13.2 with both gcc and clang using LLVM 3.9.1 libs on Fedora 25 and they all segfault the same way described above.

All stacktraces in these cases start with these:
#0 0x00007ffff59535c7 in llvm::PMTopLevelManager::schedulePass(llvm::Pass*) () from /lib64/libLLVM-3.9.so
#1 0x00007ffff62097b8 in llvm::PassManagerBuilder::addExtensionsToPM(llvm::PassManagerBuilder::ExtensionPointTy, llvm::legacy::PassManagerBase&) const () from /lib64/libLLVM-3.9.so
#2 0x00007ffff620a849 in llvm::PassManagerBuilder::populateModulePassManager(llvm::legacy::PassManagerBase&) ()
from /lib64/libLLVM-3.9.so

Below you can find the versions I tried.

0.13.1-874c0f8 [release]
compiled with: llvm 3.9.1 -- gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)

0.13.1-874c0f8 [release]
compiled with: llvm 3.9.1 -- clang version 3.9.1 (tags/RELEASE_391/final)

0.13.2-e3c67a3 [release]
compiled with: llvm 3.9.1 -- clang version 3.9.1 (tags/RELEASE_391/final)

0.13.2-e3c67a3 [release]
compiled with: llvm 3.9.1 -- gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)

@KaroLaunonen
Copy link
Contributor

The problem only arises with optimization. If I use --debug with ponyc it works fine.

So then I saw this: http://stackoverflow.com/questions/30114849/crash-on-au-addrequiredloopinfo-in-llvm-pass

And tried this:

diff --git a/src/libponyc/codegen/genopt.cc b/src/libponyc/codegen/genopt.cc
index 9a43610..ab367d9 100644
--- a/src/libponyc/codegen/genopt.cc
+++ b/src/libponyc/codegen/genopt.cc
@@ -450,6 +450,7 @@ static void addHeapToStackPass(const PassManagerBuilder& pmb,
   PassManagerBase& pm)
 {
   if(pmb.OptLevel >= 2)
+    pm.add(new DominatorTreeWrapperPass());
     pm.add(new HeapToStack());
 }
 

...and now it works!

@LaurentTreguier
Copy link

LaurentTreguier commented May 12, 2017

@KaroLaunonen this patch (with some added curly brackets) seems to fix the issue on my end

@SeanTAllen
Copy link
Member

@KaroLaunonen you up for opening a PR?

KaroLaunonen added a commit to KaroLaunonen/ponyc that referenced this issue May 14, 2017
@KaroLaunonen
Copy link
Contributor

@LaurentTreguier Ouch, that was embarrassing with those curly brackets. Thanks for pointing out! Pony syntax had already stuck on me. :)

@jemc
Copy link
Member

jemc commented May 14, 2017

Resolved by #1910 - thanks to @KaroLaunonen and everyone else who contributed to the troubleshooting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants