【问题标题】:bison 3.0.4 fails in Illegal instruction: 4 on macOS High Sierra 10.13bison 3.0.4 在非法指令中失败:macOS High Sierra 10.13 上的 4
【发布时间】:2017-10-14 00:17:33
【问题描述】:

随着 macOS 从 10.12 更新到 10.13,/usr/local/bin/bison 停止工作。

问题:

$ /usr/local/bin/bison --version
Illegal instruction: 4

重建野牛的尝试也失败了,lldb 报告 EXC_BAD_INSTRUCTION。

$ lldb src/bison
(lldb) target create "src/bison"
Current executable set to 'src/bison' (x86_64).
(lldb) run
Process 25732 launched: '/Users/xxxx/src/bison/bison-3.0.4/src/bison' (x86_64)
Process 25732 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x00007fff68e39a23 libsystem_c.dylib`__vfprintf + 16437
libsystem_c.dylib`__vfprintf:
->  0x7fff68e39a23 <+16437>: ud2    
    0x7fff68e39a25 <+16439>: nopl   (%rax)
    0x7fff68e39a28 <+16442>: retq   
Target 0: (bison) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x00007fff68e39a23 libsystem_c.dylib`__vfprintf + 16437
    frame #1: 0x00007fff68e5e0a9 libsystem_c.dylib`__v2printf + 473
    frame #2: 0x00007fff68e434c7 libsystem_c.dylib`_vsnprintf + 415
    frame #3: 0x00007fff68e43524 libsystem_c.dylib`vsnprintf_l + 41
    frame #4: 0x00007fff68e344ec libsystem_c.dylib`snprintf + 180
    frame #5: 0x00000001000465a8 bison`vasnprintf(resultbuf=<unavailable>, lengthp=<unavailable>, format=<unavailable>, args=<unavailable>) at vasnprintf.c:0 [opt]
    frame #6: 0x0000000100042916 bison`rpl_fprintf(fp=0x00007fffa211d240, format=<unavailable>) at fprintf.c:45 [opt]
    frame #7: 0x0000000100042532 bison`error(status=0, errnum=0, message="%s: missing operand") at error.c:315 [opt]
    frame #8: 0x0000000100008301 bison`getargs(argc=1, argv=0x00007ffeefbff8c0) at getargs.c:0 [opt]
    frame #9: 0x000000010000d70a bison`main(argc=1, argv=0x00007ffeefbff8c0) at main.c:81 [opt]
    frame #10: 0x00007fff68da2145 libdyld.dylib`start + 1

解决方法: 如果您使用 Xcode 9,其 gcc 版本可能是 Apple LLVM 版本 9.0.0。通过将(defined __APPLE__ &amp;&amp; __clang_major__ &gt;= 9) 添加到野牛源文件中的#if 宏来应用补丁。然后重建并重新安装它。

$ diff -u  lib/vasnprintf.c.original lib/vasnprintf.c
--- lib/vasnprintf.c.original   2015-01-05 01:46:03.000000000 +0900
+++ lib/vasnprintf.c    2017-10-13 16:38:49.000000000 +0900
@@ -4858,7 +4858,7 @@
 #endif
                   *fbp = dp->conversion;
 #if USE_SNPRINTF
-# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# if !((defined __APPLE__ && __clang_major__ >= 9) || ((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
                 fbp[1] = '%';
                 fbp[2] = 'n';
                 fbp[3] = '\0';

参考资料: https://github.com/Homebrew/homebrew-core/issues/14418

查找关键字 bison 和 %n。

在补丁行周围读取源代码中的 cmets。

如果您知道更可靠的解决方案,请告诉我们。谢谢!

【问题讨论】:

    标签: xcode bison macos-high-sierra


    【解决方案1】:

    此错误于 2017 年 9 月 16 日在bug-bison 上报告,根据当天晚些时候野牛维护者的回复,野牛源代码库在此后不久更新以修复该问题。但是,没有创建新的源分发;为了使用该修复程序,有必要与Bison Git repository 中的maint 分支同步,其中包括更新版本的gnulib。 (我相信从 maint 分支构建并不像下载源 tarball 那样简单,所以这并不完全令人满意。在有新的野牛源版本之前,您指出的修复可能是最简单的选择。)

    在 bug-gnulib 消息 linked from the bison bug report 中描述了 gnulib 修复。

    如您的链接所示,该问题影响了许多其他软件包,而不仅仅是野牛。这不算什么安慰。

    【讨论】:

      猜你喜欢
      • 2019-03-11
      • 2018-03-06
      • 1970-01-01
      • 2018-03-14
      • 1970-01-01
      • 1970-01-01
      • 2018-08-10
      • 1970-01-01
      • 2018-04-03
      相关资源
      最近更新 更多