Skip to content

Basic protobuf usage segfaults #221740

Open
Open
@mortie

Description

@mortie

brew gist-logs <formula> link OR brew config AND brew doctor output

$ brew gist-logs protobuf
Error: No logs.

$ brew config
HOMEBREW_VERSION: 4.4.32-75-g50b70e3
ORIGIN: https://github.com/Homebrew/brew
HEAD: 50b70e3cb72e994cd7f530960dfb47255fdf2a34
Last commit: 6 hours ago
Branch: master
Core tap HEAD: 6c2620ecb4d741efbff32295f0c2ef01ebd5dfca
Core tap last commit: 5 hours ago
Core tap JSON: 28 Apr 10:02 UTC
Core cask tap HEAD: ba3da943abc861c24d078b63560419d6981c4f32
Core cask tap last commit: 5 hours ago
Core cask tap JSON: 28 Apr 10:02 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nvim
HOMEBREW_MAKE_JOBS: 10
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.4.3 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.4.3/bin/ruby
CPU: deca-core 64-bit arm_firestorm_icestorm
Clang: 17.0.0 build 1700
Git: 2.49.0 => /opt/homebrew/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.4.1-arm64
CLT: 16.3.0.0.1.1742442376
Xcode: 16.3
Rosetta 2: false

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  icu4c@76

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libMoltenVK.dylib
  /usr/local/lib/libSPIRV-Tools-shared.dylib
  /usr/local/lib/libVkLayer_api_dump.dylib
  /usr/local/lib/libVkLayer_khronos_profiles.dylib
  /usr/local/lib/libVkLayer_khronos_synchronization2.dylib
  /usr/local/lib/libVkLayer_khronos_validation.dylib
  /usr/local/lib/libcorrect.dylib
  /usr/local/lib/libdxcompiler.3.7.dylib
  /usr/local/lib/libsdrpp_core.dylib
  /usr/local/lib/libshaderc_shared.1.dylib
  /usr/local/lib/libspirv-cross-c-shared.0.49.0.dylib
  /usr/local/lib/libvulkan.1.3.211.dylib

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae and may need to be deleted.

Unexpected header files:
  /usr/local/include/correct-sse.h
  /usr/local/include/correct.h
  /usr/local/include/dxc/*
  /usr/local/include/glslang/*
  /usr/local/include/shaderc/*
  /usr/local/include/spirv-tools/*
  /usr/local/include/spirv_cross/*
  /usr/local/include/vk_video/*
  /usr/local/include/vulkan/*

Warning: Unbrewed '.pc' files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae and may need to be deleted.

Unexpected '.pc' files:
  /usr/local/lib/pkgconfig/SPIRV-Tools-shared.pc
  /usr/local/lib/pkgconfig/SPIRV-Tools.pc
  /usr/local/lib/pkgconfig/shaderc.pc
  /usr/local/lib/pkgconfig/spirv-cross-c-shared.pc
  /usr/local/lib/pkgconfig/vulkan.pc

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae and may need to be deleted.

Unexpected static libraries:
  /usr/local/lib/libGenericCodeGen.a
  /usr/local/lib/libHLSL.a
  /usr/local/lib/libMachineIndependent.a
  /usr/local/lib/libOGLCompiler.a
  /usr/local/lib/libOSDependent.a
  /usr/local/lib/libSPIRV-Tools-diff.a
  /usr/local/lib/libSPIRV-Tools-link.a
  /usr/local/lib/libSPIRV-Tools-lint.a
  /usr/local/lib/libSPIRV-Tools-opt.a
  /usr/local/lib/libSPIRV-Tools-reduce.a
  /usr/local/lib/libSPIRV-Tools.a
  /usr/local/lib/libSPIRV.a
  /usr/local/lib/libSPVRemapper.a
  /usr/local/lib/libcorrect.a
  /usr/local/lib/libglslang-default-resource-limits.a
  /usr/local/lib/libglslang.a
  /usr/local/lib/libshaderc.a
  /usr/local/lib/libshaderc_combined.a
  /usr/local/lib/libshaderc_util.a
  /usr/local/lib/libspirv-cross-c.a
  /usr/local/lib/libspirv-cross-core.a
  /usr/local/lib/libspirv-cross-cpp.a
  /usr/local/lib/libspirv-cross-glsl.a
  /usr/local/lib/libspirv-cross-hlsl.a
  /usr/local/lib/libspirv-cross-msl.a
  /usr/local/lib/libspirv-cross-reflect.a
  /usr/local/lib/libspirv-cross-util.a

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

As you can see from by brew doctor output, I have the Vulkan SDK installed, and I have icu4c@76 installed because it's a dependency of a ton of packages. These things seem unrelated to the issue I'm describing here, so I will not uninstall the Vulkan SDK or icu4c@76 (+ dependents) just to make the output of brew doctor clean, unless someone specifically asks for it.

What were you trying to do (and why)?

I tried to use the Homebrew-packaged protobuf library to deserialize a serialized string.

What happened (include all command output)?

It caused a segmentation fault.

What did you expect to happen?

It to not cause a segmentation fault.

Step-by-step reproduction instructions (by running brew commands)

  1. brew install protobuf
  2. Write the following content to testmessage.proto:
syntax = "proto3";

message TestMessage {
    repeated Foo foos = 1;
}

message Foo {
  int32 x = 1;
}
  1. Write the following to main.cc:
#include "testmessage.pb.h"
#include <iostream>

int main() {
    TestMessage a;
    a.add_foos()->set_x(10);

    std::string serialized;
    if (!a.SerializeToString(&serialized)) {
        std::cerr << "Oh no, serialize failed\n";
        return 1;
    }

    std::cout << "Parsing...\n";
    TestMessage b;
    if (!b.ParseFromString(serialized)) {
        std::cerr << "Oh no, parse failed\n";
        return 1;
    }

    return 0;
}
  1. protoc --cpp_out=. testmessage.proto
  2. clang++ -std=c++20 -o main main.cc testmessage.pb.cc $(pkg-config --libs --cflags protobuf)
  3. ./main

You should see a segmentation fault error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions