Description of the problem / feature request:
Bazel will build a simple "Hello World" executable that is throwing a "Segmentation fault: 11" error.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
The build file is having the following content:
load("@rules_cc//cc:defs.bzl", "cc_binary")
cc_binary(
name = "main",
srcs = ["main.cpp"],
visibility = ["//visibility:public"],
)
Main.cpp:
#include <iostream>
int main() {
std::cout << "Hello World";
return 0;
}
What operating system are you running Bazel on?
MacOS Monterey (version 12.0.1)
What's the output of bazel info release?
release 4.2.1-homebrew
Have you found anything relevant by searching the web?
I have found something similar for earlier versions of Apple Clang.
In those cases anyway the program will through segmentation faults during the execution. In my case I will get a segmentation fault before the program is executed. (basically on anything)
https://discussions.apple.com/thread/6009790?answerId=25322969022#25322969022
I am thinking this behavior might have something to do with the default flags from the default Bazel rules for macos.
Any other information, logs, or outputs that you want to share?
I tried re-installing xcode tools, I tried cleaning bazel cache.
You can find the execution log below:
$ bazel run //src:main
INFO: Analyzed target //src:main (15 packages loaded, 61 targets configured).
INFO: Found 1 target...
Target //src:main up-to-date:
bazel-bin/src/main
INFO: Elapsed time: 1,155s, Critical Path: 0,71s
INFO: 8 processes: 6 internal, 2 darwin-sandbox.
INFO: Build completed successfully, 8 total actions
INFO: Build completed successfully, 8 total actions
zsh: segmentation fault bazel run //src:main
$ bazel clean
INFO: Starting clean.
$ bazel run -s //src:main
INFO: Analyzed target //src:main (15 packages loaded, 61 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # //src:main [action 'Compiling src/main.cpp', configuration: 51eca898bf06b62dddc4e4762e2e193fc5c16e384d78bdf88fb0dd0f0af3120c, execution platform: @local_config_platform//:host]
(cd /private/var/tmp/_bazel_timo/7b405aebb7d2c99589e84a6855442b7d/execroot/__main__ && \
exec env - \
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \
PWD=/proc/self/cwd \
external/local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer '-std=c++0x' -MD -MF bazel-out/darwin-fastbuild/bin/src/_objs/main/main.pic.d '-frandom-seed=bazel-out/darwin-fastbuild/bin/src/_objs/main/main.pic.o' -fPIC -iquote . -iquote bazel-out/darwin-fastbuild/bin -iquote external/bazel_tools -iquote bazel-out/darwin-fastbuild/bin/external/bazel_tools '-std=c++17' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c src/main.cpp -o bazel-out/darwin-fastbuild/bin/src/_objs/main/main.pic.o)
SUBCOMMAND: # //src:main [action 'Linking src/main', configuration: 51eca898bf06b62dddc4e4762e2e193fc5c16e384d78bdf88fb0dd0f0af3120c, execution platform: @local_config_platform//:host]
(cd /private/var/tmp/_bazel/7b405aebb7d2c99589e84a6855442b7d/execroot/__main__ && \
exec env - \
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \
PWD=/proc/self/cwd \
external/local_config_cc/cc_wrapper.sh @bazel-out/darwin-fastbuild/bin/src/main-2.params)
Target //src:main up-to-date:
bazel-bin/src/main
INFO: Elapsed time: 0,996s, Critical Path: 0,64s
INFO: 8 processes: 6 internal, 2 darwin-sandbox.
INFO: Build completed successfully, 8 total actions
INFO: Build completed successfully, 8 total actions
zsh: segmentation fault bazel run -s //src:main
Description of the problem / feature request:
Bazel will build a simple "Hello World" executable that is throwing a "Segmentation fault: 11" error.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
The build file is having the following content:
Main.cpp:
What operating system are you running Bazel on?
MacOS Monterey (version 12.0.1)
What's the output of
bazel info release?release 4.2.1-homebrew
Have you found anything relevant by searching the web?
I have found something similar for earlier versions of Apple Clang.
In those cases anyway the program will through segmentation faults during the execution. In my case I will get a segmentation fault before the program is executed. (basically on anything)
https://discussions.apple.com/thread/6009790?answerId=25322969022#25322969022
I am thinking this behavior might have something to do with the default flags from the default Bazel rules for macos.
Any other information, logs, or outputs that you want to share?
I tried re-installing xcode tools, I tried cleaning bazel cache.
You can find the execution log below: