Bug 216614

Summary: editors/emacs-devel: clang 4.0 crashes during build
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: Ashish SHUKLA <ashish>
Status: Closed FIXED    
Severity: Affects Only Me CC: dim
Priority: --- Keywords: needs-patch
Version: LatestFlags: bugzilla: maintainer-feedback? (ashish)
Hardware: Any   
OS: Any   
See Also: https://llvm.org/bugs/show_bug.cgi?id=31809
Bug Depends on:    
Bug Blocks: 216008    
Attachments:
Description Flags
src/buffer.c (preprocessed, compressed)
none
command line args (for clang 4.0) none

Description Jan Beich freebsd_committer 2017-01-30 21:45:12 UTC
Assertion failed: ((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"), function computeKnownBits, file /usr/src/contrib/llvm/lib/Analysis/ValueTracking.cpp, line 1594.
cc: error: unable to execute command: Abort trap
cc: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 4.0.0 (branches/release_40 293443) (based on LLVM 4.0.0)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin

http://package18.nyi.freebsd.org/data/headamd64PR216008-default/2017-01-29_16h09m05s/logs/errors/emacs-devel-26.0.50.20170121,2.log
Comment 1 Jan Beich freebsd_committer 2017-01-30 21:47:19 UTC
Created attachment 179444 [details]
src/buffer.c (preprocessed, compressed)
Comment 2 Jan Beich freebsd_committer 2017-01-30 21:47:52 UTC
Created attachment 179445 [details]
command line args (for clang 4.0)
Comment 3 Dimitry Andric freebsd_committer 2017-01-31 07:53:58 UTC
Reproduced, test case submitted in upstream bug:
https://llvm.org/bugs/show_bug.cgi?id=31809
Comment 4 commit-hook freebsd_committer 2017-02-02 23:02:29 UTC
A commit references this bug:

Author: dim
Date: Thu Feb  2 23:01:30 UTC 2017
New revision: 313110
URL: https://svnweb.freebsd.org/changeset/base/313110

Log:
  Pull in r293773 from upstream llvm trunk (by Sanjay Patel):

    [ValueTracking] avoid crashing from bad assumptions (PR31809)

    A program may contain llvm.assume info that disagrees with other
    analysis. This may be caused by UB in the program, so we must not
    crash because of that.

    As noted in the code comments:
    https://llvm.org/bugs/show_bug.cgi?id=31809
    ...we can do better, but this at least avoids the assert/crash in the
    bug report.

    Differential Revision: https://reviews.llvm.org/D29395

  This fixes an assertion when building editors/emacs-devel.

  PR:		216614

Changes:
  projects/clang400-import/contrib/llvm/lib/Analysis/ValueTracking.cpp
Comment 5 Dimitry Andric freebsd_committer 2017-02-02 23:05:48 UTC
Should be fixed now.  Note that upstream has indicated that what emacs is doing is most likely some undefined behavior, so please take care.  I have built emacs-devel with this fix, and it seems to work OK, with light testing (both in a terminal, and as an X client).