FS#34155 - [ldc] Illegal Instruction

Attached to Project: Community Packages
Opened by T. Jameson Little (beatgammit) - Tuesday, 05 March 2013, 06:23 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Tuesday, 04 June 2013, 05:17 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Architecture x86_64
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
When running a program compiled with ldc2, I get "illegal instruction".

Additional info:
* ldc 20130219-1

CPU: Intel(R) Core(TM)2 Duo CPU T6500 @ 2.10GHz


Steps to reproduce:

This simple program causes the error every time for me:

void main() {
}

Compiling ldc from source works as expected. I would just flag this as out of date, but I couldn't reproduce the error from an older version of ldc (tried last commit from 2-18 and release 0.10), so it must be a problem with the pre-compiled ldc available in the repositories.
This task depends upon

Closed by  Sven-Hendrik Haase (Svenstaro)
Tuesday, 04 June 2013, 05:17 GMT
Reason for closing:  Fixed
Additional comments about closing:  Should be fixed in current version. Reopen if it isn't.
Comment by T. Jameson Little (beatgammit) - Tuesday, 05 March 2013, 07:30 GMT
Removing the multilib compile-time switch (-DMULTILIB=$_multilib) in the PKGBUILD fixed it for me. With that switch, ldc wouldn't compile.

I'm not 100% sure what that switch does. I'm running on x86_64, so that may be relevant information that I neglected to include in the original report.
Comment by ariasuni (Sinma) - Tuesday, 05 March 2013, 16:12 GMT
I can confirm the bug, also on 64 bits.
CPU: AMD Athlon 64 ×2
I can also confirm the workaround works! :D
Comment by Sven-Hendrik Haase (Svenstaro) - Sunday, 10 March 2013, 03:09 GMT
I can not reproduce the problem. I will ask upstream.
Comment by David Nadlinger (klickverbot) - Monday, 11 March 2013, 00:29 GMT
Upstream maintainer here. Could you please run the crashing program in GDB and dump the assembly of where it crashes (using the "disas" command), so we have at least some chance to figure out what is going on here? "Illegal instruction" could be anything from a trap (e.g. assert(false)) being hit in some library to some instruction actually not supported on your CPU.

Unfortunately, I can't reproduce the issue on my Arch box.

Also, I'm not sure how MULTILIB is related to the bug report. It only triggers compilation of a separate set of, well, multilib (i.e. 32 bit) versions of druntime and Phobos. What do you mean by »With that switch, ldc wouldn't compile«?
Comment by T. Jameson Little (beatgammit) - Monday, 11 March 2013, 16:05 GMT
This is with the current repository's version of ldc2.

out.disasm was from objdump -d
out2.disasm was from objdump, but using my build without MULTILIB

Here's main (not very interesting):

(gdb) info address main
Symbol "main" is at 0x403050 in a file compiled without debugging.
(gdb) disas 0x403050
Dump of assembler code for function main:
0x0000000000403050 <+0>: mov $0x401f70,%edx
0x0000000000403055 <+5>: jmp 0x403060 <_d_run_main>
End of assembler dump.

Here's some more info (ran using gdb):

(gdb) run
Starting program: /home/otto/test
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
0x000000000041c236 in gc.gcx.GC.initialize() ()

The linux-vdso error doesn't seem significant: https://bugs.archlinux.org/task/30657 (also appears on an equivalent C program)

It seems to be this instruction: vmovups
Comment by T. Jameson Little (beatgammit) - Monday, 11 March 2013, 16:15 GMT
Interesting part of build failure:

[ 31%] Generating src/rt/arrayfloat-debug_32.o
Scanning dependencies of target druntime-ldc-debug_32
[ 31%] Building C object runtime/CMakeFiles/druntime-ldc-debug_32.dir/druntime/src/core/stdc/errno.c.o
In file included from /usr/include/features.h:399:0,
from /usr/include/errno.h:28,
from /home/otto/abs/ldc/borken/src/ldc-build/runtime/druntime/src/core/stdc/errno.c:14:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
compilation terminated.
make[2]: *** [runtime/CMakeFiles/druntime-ldc-debug_32.dir/druntime/src/core/stdc/errno.c.o] Error 1
make[1]: *** [runtime/CMakeFiles/druntime-ldc-debug_32.dir/all] Error 2
make: *** [all] Error 2
==> ERROR: A failure occurred in build().
Aborting...

Built from PKGBUILD from abs (attached) with makepkg -s

My system is relatively bare and I don't recall installing any 32-bit compat libs. My rather uninformed guess is that this is a missing dependency issue, not an upstream issue, since I can build from source using the upstream instructions.
   PKGBUILD (1.6 KiB)
Comment by Sven-Hendrik Haase (Svenstaro) - Monday, 11 March 2013, 16:16 GMT
You need gcc-multilib of course for compiling multilib. This is not a bug.
Comment by T. Jameson Little (beatgammit) - Monday, 11 March 2013, 16:21 GMT
That's what I assumed, but shouldn't this be a make-depends or something? The PKGBUILD assumes a multilib system, and that isn't default on a standard Arch install.
Comment by David Nadlinger (klickverbot) - Monday, 11 March 2013, 18:20 GMT
Thanks for the detective work. It seems like the druntime version shipped in the community repo is built with AVX enabled, but your CPU does not support it.
Comment by T. Jameson Little (beatgammit) - Monday, 11 March 2013, 18:48 GMT
That would do it. I hate to be the least common denominator though...

I guess this is something that needs to be done in the packaging, not upstream? I suppose LDC could double-check for CPU features, but this sounds like a lot of work for something that can be done at compile time.
Comment by T. Jameson Little (beatgammit) - Monday, 11 March 2013, 19:48 GMT
It looks like AVX support was added in 2011 with Intel Sandy Bridge and AMD Bulldozer: http://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX
Comment by Sven-Hendrik Haase (Svenstaro) - Monday, 01 April 2013, 08:12 GMT Comment by T. Jameson Little (beatgammit) - Tuesday, 28 May 2013, 22:51 GMT
The upstream bug report appears to be fixed now, and a new release should be coming out soon: "http://forum.dlang.org/thread/mailman.1435.1369083694.4724.digitalmars-d-ldc@puremagic.com"

It seems the Linux build should be stable, but it hasn't been officially released yet.

EDIT: The next version will be 0.11, but the current version scheme is date-based. Could the version number scheme be changed? Beta-2 has been released, so the official release version should be out soon.

Loading...