Bug 18544 - Assertion failure mini-llvm.c:4554 with -O=all for LLVM backend
Summary: Assertion failure mini-llvm.c:4554 with -O=all for LLVM backend
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-03-23 18:59 UTC by empann
Modified: 2014-04-07 16:10 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
C# source code test program (1.81 KB, text/x-csharp)
2014-03-23 18:59 UTC, empann
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description empann 2014-03-23 18:59:31 UTC
Created attachment 6393 [details]
C# source code test program

I tried to run the benchmark at http://benchmarksgame.alioth.debian.org/u64q/program.php?test=binarytrees&lang=csharp&id=1 with --llvm -O=all but it failed. It works without -O=all.

I use mono version 3.2.8 (compiled from source) and llvm from mono github (latest version, mono master branch as of 2014-03-23). I had to change
#include <llvm/Analysis/Verifier.h>
to
#include <llvm/IR/Verifier.h>
in mini-llvm-cpp.cpp before it even compiled.


$ dmcs binarytrees.cs
$ mono --llvm -O=all binarytrees.exe 20

* Assertion at mini-llvm.c:4554, condition `LLVMTypeOf (values [sreg1]) == LLVMTypeOf (values [phi->dreg])' not met

Stacktrace:

  at <unknown> <0xffffffff>
  at BinaryTrees/TreeNode.bottomUpTree (int,int) <0x00027>
  at BinaryTrees.Main (string[]) <0x00043>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

	/tmp/mon/bin/mono() [0x8111823]
	[0xb77c940c]
	[0xb77c9424]
	/lib/i386-linux-gnu/libc.so.6(gsignal+0x4f) [0xb74e21df]
	/lib/i386-linux-gnu/libc.so.6(abort+0x175) [0xb74e5825]
	/tmp/mon/bin/mono() [0x82a8240]
	/tmp/mon/bin/mono() [0x82a82c3]
	/tmp/mon/bin/mono() [0x814bed9]
	/tmp/mon/bin/mono() [0x80795fc]
	/tmp/mon/bin/mono() [0x807aa43]
	/tmp/mon/bin/mono() [0x807b63e]
	/tmp/mon/bin/mono() [0x811438a]
	[0xb72a003e]

(gdb) bt
#0  0xb77c9424 in __kernel_vsyscall ()
#1  0xb74e21df in raise () from /lib/i386-linux-gnu/libc.so.6
#2  0xb74e5825 in abort () from /lib/i386-linux-gnu/libc.so.6
#3  0x0811193e in mono_handle_native_sigsegv (signal=6, ctx=0xbff2a79c) at mini-exceptions.c:2335
#4  <signal handler called>
#5  0xb77c9424 in __kernel_vsyscall ()
#6  0xb74e21df in raise () from /lib/i386-linux-gnu/libc.so.6
#7  0xb74e5825 in abort () from /lib/i386-linux-gnu/libc.so.6
#8  0x082a8240 in monoeg_g_logv (log_domain=0x0, log_level=G_LOG_LEVEL_ERROR, format=0x8dcf164 "* Assertion at %s:%d, condition `%s' not met\n", args=
    0xbff2ad94 "CW\336\b\312\021") at goutput.c:175
#9  0x082a82c3 in monoeg_assertion_message (format=0x8dcf164 "* Assertion at %s:%d, condition `%s' not met\n") at goutput.c:195
#10 0x0814bed9 in mono_llvm_emit_method (cfg=0x9aba7a8) at mini-llvm.c:4554
#11 0x080795fc in mini_method_compile (method=<error reading variable: Address 0xb77c15e4 out of bounds>, opts=4143840767, domain=0x9a02a50, flags=
    JIT_FLAG_RUN_CCTORS, parts=0) at mini.c:5600
#12 0x0807aa43 in mono_jit_compile_method_inner (jit_ex=0xbff2b24c, opt=-151126529, target_domain=0x9a02a50, method=
    <error reading variable: Address 0xb77c15e4 out of bounds>) at mini.c:5940
#13 mono_jit_compile_method_with_opt (method=<error reading variable: Address 0xb77c15e4 out of bounds>, opt=4143840767, ex=0xbff2b24c) at mini.c:6211
#14 0x0807b63e in mono_jit_compile_method (method=<error reading variable: Address 0xb77c15e4 out of bounds>) at mini.c:6248
#15 0x0811438a in common_call_trampoline (regs=0xbff2b318, code=0xb71fd318 "\213D$\030\203\304", <incomplete sequence \303>, m=
    <error reading variable: Address 0xb77c15e4 out of bounds>, vt=0x0, vtable_slot=<optimized out>, need_rgctx_tramp=0, tramp=<optimized out>)
    at mini-trampolines.c:576
#16 0xb72a003e in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Comment 1 Zoltan Varga 2014-03-24 09:06:54 UTC
I can't reproduce this. Make sure you use the 'mono' branch of the mono llvm repository.
What is the output of mono --version ?
Comment 2 Zoltan Varga 2014-03-24 09:26:58 UTC
Also please try using the tip of the mono-3.4.0-branch.
Comment 3 empann 2014-03-30 14:03:36 UTC
Hi. I used the master branch of mono llvm. The same problem seems to happen also with the mono branch of mono llvm. I use Ubuntu 12.04.4 LTS on x86_64.

This is what I do:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

$ cd /tmp
$ mkdir m
$ cd m
$ mkdir prefix

$ wget https://github.com/mono/llvm/archive/mono.zip
$ unzip mono.zip
$ cd llvm-mono
$ ./configure --prefix=/tmp/m/prefix --enable-optimized --enable-targets="x86 x86_64" --disable-compiler-version-checks --disable-terminfo
$ make -j8
$ make install
$ cd ..

$ wget http://download.mono-project.com/sources/mono/mono-3.2.8.tar.bz2
$ tar xf mono-3.2.8.tar.bz2
$ cd mono-3.2.8
$ ./configure --prefix=/tmp/m/prefix --enable-llvm --with-llvm=/tmp/m/prefix

        mcs source:    mcs

   Engine:
        GC:            sgen and bundled Boehm GC with typed GC and parallel mark
        TLS:           __thread
        SIGALTSTACK:   yes
        Engine:        Building and using the JIT
        oprofile:      no
        BigArrays:     no
        DTrace:        no
        LLVM Back End: yes (dynamically loaded: no)

   Libraries:
        .NET 2.0/3.5:  yes
        .NET 4.0:      yes
        .NET 4.5:      yes
        MonoDroid:     no
        MonoTouch:     no
        JNI support:   IKVM Native
        libgdiplus:    assumed to be installed
        zlib:          system zlib


$ make -j8
  ...
  CXX    mini-llvm-cpp.lo
mini-llvm-cpp.cpp:40:36: fatal error: llvm/Analysis/Verifier.h: No such file or directory
compilation terminated.

Then I changed
#include <llvm/Analysis/Verifier.h>
to
#include <llvm/IR/Verifier.h>

$ make -j8
$ make install

$ /tmp/m/prefix/bin/mono --version
Mono JIT compiler version 3.2.8 (tarball Sun Mar 30 19:39:12 CEST 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll	
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          yes(3.5svn-mono-/)
        GC:            sgen


Then it crashes:
$ /tmp/m/prefix/bin/dmcs binarytrees.cs
$ /tmp/m/prefix/bin/mono --llvm -O=all binarytrees.exe 20
* Assertion at mini-llvm.c:4554, condition `LLVMTypeOf (values [sreg1]) == LLVMTypeOf (values [phi->dreg])' not met

Stacktrace:

  at <unknown> <0xffffffff>
  at BinaryTrees/TreeNode.bottomUpTree (int,int) <0x00018>
  at BinaryTrees.Main (string[]) <0x00040>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        /tmp/m/prefix/bin/mono() [0x4c0c76]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0) [0x7f8b96089cb0]
        /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x35) [0x7f8b95ada425]
        /lib/x86_64-linux-gnu/libc.so.6(abort+0x17b) [0x7f8b95addb8b]
        /tmp/m/prefix/bin/mono() [0x65295d]
        /tmp/m/prefix/bin/mono() [0x652a96]
        /tmp/m/prefix/bin/mono() [0x4fa399]
        /tmp/m/prefix/bin/mono() [0x4353b3]
        /tmp/m/prefix/bin/mono() [0x43676e]
        /tmp/m/prefix/bin/mono() [0x43731b]
        /tmp/m/prefix/bin/mono() [0x4c33f8]
        [0x41acb166]

Debug info from gdb:

Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No threads.

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

Aborted
Comment 4 Zoltan Varga 2014-03-30 14:30:40 UTC
Could you try revision e656caccc7dfb5c51c208906f0e176f0973f030f in the mono llvm repository ? Thats the revision which matches 3.2.8.
Comment 5 empann 2014-03-30 16:33:49 UTC
I tried the e656caccc7dfb5c51c208906f0e176f0973f030f revision (https://github.com/mono/llvm/archive/e656caccc7dfb5c51c208906f0e176f0973f030f.zip), and it fails in the same way.

And as you probably know, llvm/Analysis/Verifier.h is the correct location in that branch.

Note that it crashes only when I run mono with the parameters --llvm -O=all. It works with only --llvm.
Comment 6 Zoltan Varga 2014-04-05 23:17:35 UTC
Still can't reproduce this, tried with the tip of the mono-3.4.0-branch (6272eafb17079cd17129c3a2ed7d891a71485641), and the tip of the mono llvm branch (714a9d742af9ce911a3a46aa6e55041099a04be1).
Comment 7 empann 2014-04-06 21:04:26 UTC
I just tested with the released mono version 3.4.0 and the mono llvm branch 714a9d742af9ce911a3a46aa6e55041099a04be1. That combination didn't crash :)
Comment 8 Zoltan Varga 2014-04-07 16:10:47 UTC
Turns it this was fixed in 3.4.0/master by 19362c66eec49d7a5da038e9796072a5cec82e8f.

Now its also fixed on the 3.2.8 branch by 7aab49b912ad0db1987bfb0eb2caff43052ebe84.