Skip to content

protoc segfaults on macOS 12 Beta if built with bazel #8884

@f355

Description

@f355

Hi!

I'm using protobuf as a Bazel dependency in my project and since upgrading to macOS Monterey Beta protoc has started segfaulting.

I'm running macOS Monterey 12.0 Beta (21A5304g), x86_64, with Command Line Tools for Xcode 13 beta 5 and Bazel 4.1.0.

Steps to reproduce:

  1. clone this repo
  2. bazel build //:protoc
  3. ./bazel-bin/protoc
  4. it crashes with Segmentation fault (11) instead of printing the usage screen. Needless to say, invoking it with real arguments crashes as well.

I've tried building it with autotools and it works just fine, so I assume it's something with the compiler/linker options in Bazel that breaks things. Unfortunately, my clang-fu is not nearly strong enough to figure out the cause myself.

Here's the backtrace from lldb:

$ lldb ./bazel-bin/protoc
(lldb) target create "./bazel-bin/protoc"
Current executable set to '/Users/konstantin/src/protobuf/bazel-bin/protoc' (x86_64).
(lldb) run
Process 54067 launched: '/Users/konstantin/src/protobuf/bazel-bin/protoc' (x86_64)
Process 54067 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xffffffffffffffe8)
    frame #0: 0x00007ff80194ac3c libc++.1.dylib`std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) + 16
libc++.1.dylib`std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry:
->  0x7ff80194ac3c <+16>: movq   -0x18(%rax), %rax
    0x7ff80194ac40 <+20>: cmpl   $0x0, 0x20(%rsi,%rax)
    0x7ff80194ac45 <+25>: jne    0x7ff80194ac5f            ; <+51>
    0x7ff80194ac47 <+27>: movq   %rdi, %rbx
Target 0: (protoc) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xffffffffffffffe8)
  * frame #0: 0x00007ff80194ac3c libc++.1.dylib`std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) + 16
    frame #1: 0x00000001000201a7 protoc`std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) + 39
    frame #2: 0x0000000100006889 protoc`std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) + 57
    frame #3: 0x00000001000118fd protoc`google::protobuf::compiler::CommandLineInterface::PrintHelpText() + 45
    frame #4: 0x000000010000bc01 protoc`google::protobuf::compiler::CommandLineInterface::ParseArguments(int, char const* const*) + 497
    frame #5: 0x000000010000a119 protoc`google::protobuf::compiler::CommandLineInterface::Run(int, char const* const*) + 57
    frame #6: 0x00000001000021d9 protoc`google::protobuf::compiler::ProtobufMain(int, char**) + 1785
    frame #7: 0x0000000100002892 protoc`main + 34
    frame #8: 0x0000000100bd54d5 dyld`start + 421

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions