libllvm3.2 3.2-2ubuntu3 upgrade (r600-snapshot.diff) breaks ABI, makes clang emit crashing code

Bug #1131614 reported by Anders Kaseorg
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
llvm-3.2 (Ubuntu)
Fix Released
Critical
Timo Aaltonen
Raring
Fix Released
Critical
Timo Aaltonen

Bug Description

The libllvm3.2 3.2-2ubuntu2 → 3.2-2ubuntu3 upgrade, which added r600-snapshot.diff, has broken the ABI in such a way that clang now emits code that crashes at runtime!

$ cat catch.cc
struct E {};
int main()
{
    try {
        throw E();
    } catch (E e) {
    }
    return 0;
}
$ clang++ catch.cc -o catch
$ ./catch
$ sudo aptitude upgrade libllvm3.2

Preparing to replace libllvm3.2:amd64 3.2-2ubuntu2 (using .../libllvm3.2_3.2-2ubuntu3_amd64.deb) ...

$ clang++ catch.cc -o catch
$ ./catch
Segmentation fault (core dumped)

Comparing the generated LLVM source, the difference is that a call to llvm.eh.typeid.for has been replaced with a bogus call to llvm.eh.sjlj.setjmp. The problem, I think, is that the patch has inserted an entry for llvm.ceil into the alphabetized enums and arrays in /usr/include/llvm-3.2/llvm/Intrinsics.gen, so that the numerical index that previously referred to llvm.eh.typeid.for now refers to the previous entry llvm.eh.sjlj.setjmp. The patch also inserts many other entries later in the alphabet, and who knows what effect that will have on clang and other programs.

ABI breaks need to be accompanied with a corresponding soname bump.

ProblemType: Bug
DistroRelease: Ubuntu 13.04
Package: libllvm3.2 3.2-2ubuntu3
ProcVersionSignature: Ubuntu 3.8.0-7.15-generic 3.8.0
Uname: Linux 3.8.0-7-generic x86_64
NonfreeKernelModules: openafs
ApportVersion: 2.8-0ubuntu4
Architecture: amd64
Date: Fri Feb 22 02:41:38 2013
EcryptfsInUse: Yes
InstallationDate: Installed on 2010-12-05 (809 days ago)
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Alpha amd64 (20101202)
MarkForUpload: True
SourcePackage: llvm-3.2
UpgradeStatus: Upgraded to raring on 2012-11-15 (98 days ago)

Revision history for this message
Anders Kaseorg (andersk) wrote :
Matthias Klose (doko)
Changed in llvm-3.2 (Ubuntu):
importance: Undecided → Critical
milestone: none → ubuntu-13.04-beta-1
Changed in llvm-3.2 (Ubuntu Raring):
assignee: nobody → Timo Aaltonen (tjaalton)
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in llvm-3.2 (Ubuntu):
status: New → Confirmed
Revision history for this message
Tom Stellard (w-tom) wrote :

Does reverting the commit 4f0a34e93e0c78320545f7a31fd35c7efc597d1a which adds the ceil intrinsic fix this bug. If so, I'll revert that commit in the R600 llvm tree. I think I'd prefer to maintain ABI compatibility rather than bump the so name, and that change is not really critical.

Revision history for this message
Anders Kaseorg (andersk) wrote :

I don’t know, but ceil is far from the only intrinsic that was inserted into the middle of the sorted list:

@@ -2636,2 +2655,3 @@
   "llvm.bswap",
+ "llvm.ceil",
   "llvm.convert.from.fp16",
@@ -3678,2 +3698,3 @@
   "llvm.mips.wrdsp",
+ "llvm.nearbyint",
   "llvm.nvvm.abs.i",
@@ -4155,4 +4176,20 @@
   "llvm.ptx.read.warpid",
+ "llvm.r600.read.global.size.x",
+ "llvm.r600.read.global.size.y",
+ "llvm.r600.read.global.size.z",
+ "llvm.r600.read.local.size.x",
+ "llvm.r600.read.local.size.y",
+ "llvm.r600.read.local.size.z",
+ "llvm.r600.read.ngroups.x",
+ "llvm.r600.read.ngroups.y",
+ "llvm.r600.read.ngroups.z",
+ "llvm.r600.read.tgid.x",
+ "llvm.r600.read.tgid.y",
+ "llvm.r600.read.tgid.z",
+ "llvm.r600.read.tidig.x",
+ "llvm.r600.read.tidig.y",
+ "llvm.r600.read.tidig.z",
   "llvm.readcyclecounter",
   "llvm.returnaddress",
+ "llvm.rint",
   "llvm.sadd.with.overflow",
@@ -4251,2 +4288,3 @@
   "llvm.trap",
+ "llvm.trunc",
   "llvm.uadd.with.overflow",

Revision history for this message
Tom Stellard (w-tom) wrote :

Can you test this branch?

http://cgit.freedesktop.org/~tstellar/llvm/log/?h=9.1-abi-fix

It removes all the extra intrinsics and will hopefully fix this bug.

Revision history for this message
Anders Kaseorg (andersk) wrote :

I built that to https://launchpad.net/~anders-kaseorg/+archive/ppa, and it seems to fix the clang problems. I also reviewed the diff between llvm-3.2-dev 3.2-2ubuntu2 and llvm-3.2-dev 3.2-2ubuntu3andersk1 and didn’t see any obvious red flags. Thanks.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package llvm-3.2 - 3.2-2ubuntu4

---------------
llvm-3.2 (3.2-2ubuntu4) raring; urgency=low

  * r600-snapshot.diff: Updated, no longer changes the ABI (LP: #1131614).
 -- Timo Aaltonen <email address hidden> Wed, 27 Feb 2013 10:50:10 +0200

Changed in llvm-3.2 (Ubuntu Raring):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.