Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile on CentOS 7 #22

Closed
jeroen-dhollander opened this issue Mar 19, 2018 · 1 comment
Closed

Can't compile on CentOS 7 #22

jeroen-dhollander opened this issue Mar 19, 2018 · 1 comment

Comments

@jeroen-dhollander
Copy link

Issue Description

I am having trouble compiling open/r on my Centos 7 system.
I'm probably doing something wrong, but I can't figure out what the correct steps are.

Environment

  • tag or commit hash on which this occured
    master
  • OS version: <e.g. ubuntu-16.04>
    CentOs 7

Minimal test code / Steps to reproduce the issue

  1. Create docker image (using the command described in make_docker_context.py)

This immediately fails

tmp/openr/build/fbcode_builder (master=) > cd $(./make_docker_context.py) && docker build . 2>&1 | tee log
INFO: Docker ccache not enabled
Traceback (most recent call last):
  File "./make_docker_context.py", line 173, in <module>
    config['github_project'],
  File "./make_docker_context.py", line 154, in make_docker_context
    dockerfile = builder.render(get_steps_fn(builder))
  File "/tmp/openr/build/fbcode_builder/fbcode_builder.py", line 136, in render
    .format(unused_options)
RuntimeError: Unused options: set([u'prefix', u'make_parallelism', u'projects_dir']) -- please check if you made a typo in any of them. Those that are truly not useful should be not be set so that this typo detection can be useful.
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/jeroend/Dockerfile: no such file or directory
~ > 
  1. I then removed the unused_options check from fbcode_builder.py, and tried again. Now the image compiles
/tmp/openr/build/fbcode_builder (master %=) > git diff
diff --git a/build/fbcode_builder/fbcode_builder.py b/build/fbcode_builder/fbcode_builder.py
index 1a6993a..739154f 100644
--- a/build/fbcode_builder/fbcode_builder.py
+++ b/build/fbcode_builder/fbcode_builder.py
@@ -128,13 +128,6 @@ class FBCodeBuilder(object):
         # been used.
         unused_options = set(self._options_do_not_access)
         unused_options -= self.options_used
-        if unused_options:
-            raise RuntimeError(
-                'Unused options: {0} -- please check if you made a typo '
-                'in any of them. Those that are truly not useful should '
-                'be not be set so that this typo detection can be useful.'
-                .format(unused_options)
-            )
         return res
 
     def build(self, steps):
/tmp/openr/build/fbcode_builder (master *%=) > 
/tmp/openr/build/fbcode_builder (master *%=) > cd $(./make_docker_context.py) && docker build . 2>&1 | tee log
<sinp lots of output>
Successfully built 079a3c8040c3
  1. Try compiling the code using ./docker_build_with_ccache.sh

It fails if I use the ccache

/tmp/docker-context-mvFCnz > /tmp/openr/build/fbcode_builder/docker_build_with_ccache.sh /tmp/cache
+ set -o pipefail
+ build_timeout=
+ [[ 1 -gt 0 ]]
+ case "$1" in
+ break
+ [[ 1 != 1 ]]
+ save_ccache_to_dir=/tmp/cache
+ [[ /tmp/cache != '' ]]
+ mkdir -p /tmp/cache
++ rand_guid
+++ date +%s
++ echo 1521478565_9956_27894_5146_26603
+ id=fbcode_builder_image_id=1521478565_9956_27894_5146_26603
++ mktemp
+ logfile=/tmp/tmp.KgXTEGC6zv
+ echo '


Running build with timeout '\'''\'', label fbcode_builder_image_id=1521478565_9956_27894_5146_26603, and log in /tmp/tmp.KgXTEGC6zv


'



Running build with timeout '', label fbcode_builder_image_id=1521478565_9956_27894_5146_26603, and log in /tmp/tmp.KgXTEGC6zv



+ [[ '' != '' ]]
+ build_exit_code=0
+ docker build --label=fbcode_builder_image_id=1521478565_9956_27894_5146_26603 .
+ tee /tmp/tmp.KgXTEGC6zv
Sending build context to Docker daemon   5.12kB
Step 1/12 : FROM debian:8.6
 ---> 19134a8202e7
Step 2/12 : SHELL ["/bin/bash", "-c"]
 ---> Using cache
 ---> 37507f1aa58c
Step 3/12 : RUN apt-get update && apt-get install -yq autoconf-archive bison build-essential cmake curl flex git gperf joe libboost-all-dev libcap-dev libdouble-conversion-dev libevent-dev libgflags-dev libgoogle-glog-dev libkrb5-dev libnuma-dev libsasl2-dev libsnappy-dev libsqlite3-dev libssl-dev libtool netcat-openbsd pkg-config sudo unzip wget
 ---> Using cache
 ---> cac66493e924
Step 4/12 : RUN apt-get install -yq gcc-'4.9' g++-'4.9'
 ---> Using cache
 ---> 1d00ce6dac00
Step 5/12 : RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-'4.9' 40 --slave /usr/bin/g++ g++ /usr/bin/g++-'4.9'
 ---> Using cache
 ---> c21c887a8245
Step 6/12 : RUN update-alternatives --config gcc
 ---> Using cache
 ---> bec46e10c6f0
Step 7/12 : RUN echo deb http://ftp.debian.org/debian jessie-backports main >> /etc/apt/sources.list.d/jessie-backports.list && apt-get update && apt-get -yq -t jessie-backports install cmake
 ---> Using cache
 ---> 9f2f2100381b
Step 8/12 : USER 'nobody'
 ---> Using cache
 ---> 24b9a03e380e
Step 9/12 : RUN hostname
 ---> Using cache
 ---> 7962ada47660
Step 10/12 : RUN cat /etc/issue
 ---> Using cache
 ---> 0be48d3d1843
Step 11/12 : RUN g++ --version || echo g++ not installed
 ---> Using cache
 ---> 079a3c8040c3
Step 12/12 : LABEL "fbcode_builder_image_id"='1521478565_9956_27894_5146_26603'
 ---> Running in cacf18843e07
Removing intermediate container cacf18843e07
 ---> dab0c279a05f
Successfully built dab0c279a05f
+ echo '
FBCODE_BUILDER_EXIT'
+ [[ /tmp/cache == '' ]]
++ docker images --filter label=fbcode_builder_image_id=1521478565_9956_27894_5146_26603 -a -q
+ img=dab0c279a05f
+ [[ dab0c279a05f == '' ]]
++ echo dab0c279a05f
++ wc -l
+ [[ 1 != 1 ]]
++ rand_guid
+++ date +%s
++ echo 1521478571_9922_10392_11253_31447
+ container_name=fbcode_builder_container_1521478571_9922_10392_11253_31447
+ echo 'Starting fbcode_builder_container_1521478571_9922_10392_11253_31447 from latest image of the build with fbcode_builder_image_id=1521478565_9956_27894_5146_26603 --'
Starting fbcode_builder_container_1521478571_9922_10392_11253_31447 from latest image of the build with fbcode_builder_image_id=1521478565_9956_27894_5146_26603 --
+ echo dab0c279a05f
dab0c279a05f
+ export DOCKER_CONTENT_TRUST=
+ DOCKER_CONTENT_TRUST=
+ docker run --user root --name fbcode_builder_container_1521478571_9922_10392_11253_31447 dab0c279a05f /bin/bash -c '
    build_exit_code=0

    # Might be useful if debugging whether max cache size is too small?
    grep " Cleaning up cache directory " /tmp/ccache.log

    export CCACHE_DIR=/ccache
    ccache -s

    echo "Total bytes in /ccache:";
    total_bytes=$(du -sb /ccache | awk "{print \$1}")
    echo "$total_bytes"

    echo "Used bytes in /ccache:";
    used_bytes=$(
      du -sb $(find /ccache -type f -newermt @$(
        cat /FBCODE_BUILDER_CCACHE_START_TIME
      )) | awk "{t += \$1} END {print t}"
    )
    echo "$used_bytes"

    # Goal: set the max cache to 750MB over 125% of the usage of a
    # successful build.  If this is too small, it takes too long to get a
    # cache fully warmed up.  Plus, ccache cleans 100-200MB before reaching
    # the max cache size, so a large margin is essential to prevent misses.
    desired_mb=$(( 750 + used_bytes / 800000 )) # 125% in decimal MB: 1e6/1.25
    if [[ "$build_exit_code" != "0" ]] ; then
      # For a bad build, disallow shrinking the max cache size. Instead of
      # the max cache size, we use on-disk size, which ccache keeps at least
      # 150MB under the actual max size, hence the 400MB safety margin.
      cur_max_mb=$(( 400 + total_bytes / 1000000 ))  # ccache uses decimal MB
      if [[ "$desired_mb" -le "$cur_max_mb" ]] ; then
        desired_mb=""
      fi
    fi

    if [[ "$desired_mb" != "" ]] ; then
      echo "Updating cache size to $desired_mb MB"
      ccache -M "${desired_mb}M"
      ccache -s
    fi

    # Subshell because `time` the binary may not be installed.
    if (time tar czf /ccache.tgz /ccache) ; then
      ls -l /ccache.tgz
    else
      # This `else` ensures we never overwrite the current cache with
      # partial data in case of error, even if somebody adds code below.
      rm /ccache.tgz
      exit 1
    fi
    '
grep: /tmp/ccache.log: No such file or directory
/bin/bash: line 7: ccache: command not found
Total bytes in /ccache:
du: cannot access '/ccache': No such file or directory

Used bytes in /ccache:
cat: /FBCODE_BUILDER_CCACHE_START_TIME: No such file or directory
find: I cannot figure out how to interpret `@' as a date or time
du: cannot access './proc/13/task/13/fd/3': No such file or directory
du: cannot access './proc/13/task/13/fdinfo/3': No such file or directory
du: cannot access './proc/13/fd/4': No such file or directory
du: cannot access './proc/13/fdinfo/4': No such file or directory
2071708200
Updating cache size to 3339 MB
/bin/bash: line 38: ccache: command not found
/bin/bash: line 39: ccache: command not found
tar: Removing leading `/' from member names
tar: /ccache: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

real	0m0.002s
user	0m0.000s
sys	0m0.002s

It does pass if I disable the ccache:

/tmp/docker-context-mvFCnz > /tmp/openr/build/fbcode_builder/docker_build_with_ccache.sh ""
+ set -o pipefail
+ build_timeout=
+ [[ 1 -gt 0 ]]
+ case "$1" in
+ break
+ [[ 1 != 1 ]]
+ save_ccache_to_dir=
+ [[ '' != '' ]]
+ echo 'WARNING: Will not save /ccache from inside the Docker container'
WARNING: Will not save /ccache from inside the Docker container
++ rand_guid
+++ date +%s
++ echo 1521478610_27076_28927_5321_15199
+ id=fbcode_builder_image_id=1521478610_27076_28927_5321_15199
++ mktemp
+ logfile=/tmp/tmp.5xmlGKikgz
+ echo '


Running build with timeout '\'''\'', label fbcode_builder_image_id=1521478610_27076_28927_5321_15199, and log in /tmp/tmp.5xmlGKikgz


'



Running build with timeout '', label fbcode_builder_image_id=1521478610_27076_28927_5321_15199, and log in /tmp/tmp.5xmlGKikgz



+ [[ '' != '' ]]
+ build_exit_code=0
+ docker build --label=fbcode_builder_image_id=1521478610_27076_28927_5321_15199 .
+ tee /tmp/tmp.5xmlGKikgz
Sending build context to Docker daemon   5.12kB
Step 1/12 : FROM debian:8.6
 ---> 19134a8202e7
Step 2/12 : SHELL ["/bin/bash", "-c"]
 ---> Using cache
 ---> 37507f1aa58c
Step 3/12 : RUN apt-get update && apt-get install -yq autoconf-archive bison build-essential cmake curl flex git gperf joe libboost-all-dev libcap-dev libdouble-conversion-dev libevent-dev libgflags-dev libgoogle-glog-dev libkrb5-dev libnuma-dev libsasl2-dev libsnappy-dev libsqlite3-dev libssl-dev libtool netcat-openbsd pkg-config sudo unzip wget
 ---> Using cache
 ---> cac66493e924
Step 4/12 : RUN apt-get install -yq gcc-'4.9' g++-'4.9'
 ---> Using cache
 ---> 1d00ce6dac00
Step 5/12 : RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-'4.9' 40 --slave /usr/bin/g++ g++ /usr/bin/g++-'4.9'
 ---> Using cache
 ---> c21c887a8245
Step 6/12 : RUN update-alternatives --config gcc
 ---> Using cache
 ---> bec46e10c6f0
Step 7/12 : RUN echo deb http://ftp.debian.org/debian jessie-backports main >> /etc/apt/sources.list.d/jessie-backports.list && apt-get update && apt-get -yq -t jessie-backports install cmake
 ---> Using cache
 ---> 9f2f2100381b
Step 8/12 : USER 'nobody'
 ---> Using cache
 ---> 24b9a03e380e
Step 9/12 : RUN hostname
 ---> Using cache
 ---> 7962ada47660
Step 10/12 : RUN cat /etc/issue
 ---> Using cache
 ---> 0be48d3d1843
Step 11/12 : RUN g++ --version || echo g++ not installed
 ---> Using cache
 ---> 079a3c8040c3
Step 12/12 : LABEL "fbcode_builder_image_id"='1521478610_27076_28927_5321_15199'
 ---> Running in e9c316ce087f
Removing intermediate container e9c316ce087f
 ---> f6f291c9c678
Successfully built f6f291c9c678
+ echo '
FBCODE_BUILDER_EXIT'
+ [[ '' == '' ]]
+ echo 'Not inspecting Docker build, since saving the ccache wasn'\''t requested.'
Not inspecting Docker build, since saving the ccache wasn't requested.
+ exit 0
/tmp/docker-context-mvFCnz >

At this point, I'm not sure what to do next.

  1. I then tried to simply launch the docker image, and build from there.

This fails to compile gflags:

docker run -ti -v /tmp:/tmp -u root  f6f291c9c678 bash
root@12235d10cf61:/# cd /tmp/openr/build


/tmp/openr/build/fbcode_builder (master *%=) > docker run -ti -v /tmp:/tmp -u root  fbcode_builder_image_id bash
root@6295adfdc0c5:/tmp# cd /tmp/openr/build/
root@12235d10cf61:/tmp/openr/build# ./build_openr.sh 
+++ dirname ./build_openr.sh
++ readlink -f .
+ BUILD_DIR=/tmp/openr/build
+ export DESTDIR=
+ DESTDIR=
+ mkdir -p /tmp/openr/build/deps
+ cd /tmp/openr/build/deps
+ sudo apt-get update
Ign http://deb.debian.org jessie InRelease                       
<snip lots of updates of packages>
ging_unittest.o `test -f 'src/logging_unittest.cc' || echo './'`src/logging_unittest.cc
src/logging_unittest.cc:64:17: error: 'GFLAGS_NAMESPACE' is not a namespace-name
 using namespace GFLAGS_NAMESPACE;
                 ^
src/logging_unittest.cc:64:33: error: expected namespace-name before ';' token
 using namespace GFLAGS_NAMESPACE;
                                 ^
Makefile:1275: recipe for target 'src/logging_unittest-logging_unittest.o' failed
make: *** [src/logging_unittest-logging_unittest.o] Error 1
root@6295adfdc0c5:/tmp/openr/build# 

What's the actual result?

See errors in steps-to-reproduce.

What's the expected result?

Being able to compile and use open/r.

I'm fine with either compiling natively on CentOS 7, or in the docker image.

Thanks for the help,

Jeroen

@jeroen-dhollander
Copy link
Author

After reading the help from make_docker_context.py, I realized I was building a debian image instead of an ubuntu image,
so that is why the build_openr.sh script fails.

So please ignore this issue.

facebook-github-bot pushed a commit that referenced this issue Oct 12, 2020
Summary:
As titled, several different approaches have been added to address original issue of crash when eventbase is destructed. See P135204939

```
(gdb) bt
#0  0x000000000187ea8e in re2::RE2::Set::Match (this=0x2, text=..., v=0x7fffd8c0d500, error_info=0x0) at re2/set.cc:110
#1  0x000000000072d304 in openr::KeyPrefix::keyMatch (this=<optimized out>, key=...) at openr/common/Util.cpp:50
#2  0x00000000006d3649 in openr::KvStoreFilters::keyMatch (this=0x7fb22c613660, key=..., value=...) at openr/kvstore/KvStore.cpp:69
#3  0x00000000006d60e4 in openr::KvStore::mergeKeyValues (kvStore=..., keyVals=..., filters=...) at openr/kvstore/KvStore.cpp:246
#4  0x00000000006e3813 in openr::KvStoreDb::mergePublication (this=0x7fb232fbad28, rcvdPublication=..., senderId=...)
    at openr/kvstore/KvStore.cpp:2835
#5  0x00000000006e32d7 in openr::KvStoreDb::processThriftSuccess (this=0x7fb232fbad28, peerName=..., pub=..., timeDelta=...)
    at openr/kvstore/KvStore.cpp:1395
#6  0x000000000070487b in openr::KvStoreDb::requestThriftPeerSync()::$_19::operator()(openr::thrift::Publication&&) const (
    this=<optimized out>, pub=...) at openr/kvstore/KvStore.cpp:1338
#7  folly::futures::detail::wrapInvoke<openr::thrift::Publication, openr::KvStoreDb::requestThriftPeerSync()::$_19>(folly::Try<openr::thrift::Publication>&&, openr::KvStoreDb::requestThriftPeerSync()::$_19&&)::{lambda()#1}::operator()() const (this=<optimized out>)
    at folly/futures/Future-inl.h:99
#8  folly::futures::detail::InvokeResultWrapper<void>::wrapResult<folly::futures::detail::wrapInvoke<openr::thrift::Publication, openr::KvStoreDb::requestThriftPeerSync()::$_19>(folly::Try<openr::thrift::Publication>&&, openr::KvStoreDb::requestThriftPeerSync()::$_19&&)::{lambda()#1}>(folly::futures::detail::wrapInvoke<openr::thrift::Publication, openr::KvStoreDb::requestThriftPeerSync()::$_19>(folly::Try<openr::thrift::Publication>&&, openr::KvStoreDb::requestThriftPeerSync()::$_19&&)::{lambda()#1}) (fn=...) at folly/futures/Future-inl.h:91
#9  folly::futures::detail::wrapInvoke<openr::thrift::Publication, openr::KvStoreDb::requestThriftPeerSync()::$_19>(folly::Try<openr::thrift::Publication>&&, openr::KvStoreDb::requestThriftPeerSync()::$_19&&) (t=..., f=...) at folly/futures/Future-inl.h:109
#10 folly::Future<openr::thrift::Publication>::thenValue<openr::KvStoreDb::requestThriftPeerSync()::$_19>(openr::KvStoreDb::requestThriftPeerSync()::$_19&&) &&::{lambda(folly::Executor::KeepAlive<folly::Executor>&&, folly::Try<openr::thrift::Publication>&&)#1}::operator()(folly::Executor::KeepAlive<folly::Executor>&&, folly::Try<openr::thrift::Publication>&&) (this=<optimized out>, t=...)
    at folly/futures/Future-inl.h:1033
#11 folly::futures::detail::CoreCallbackState<folly::Unit, folly::Future<openr::thrift::Publication>::thenValue<openr::KvStoreDb::requestThriftPeerSync()::$_19>(openr::KvStoreDb::requestThriftPeerSync()::$_19&&) &&::{lambda(folly::Executor::KeepAlive<folly::Executor>&&, folly::Try<openr::thrift::Publication>&&)#1}>::invoke<folly::Executor::KeepAlive<folly::Executor>, folly::Try<openr::thrift::Publication> >(folly::Executor::KeepAlive<folly::Executor>&&, folly::Try<openr::thrift::Publication>&&) (this=<optimized out>, args=..., args=...)
    at folly/futures/Future-inl.h:145
...
#19 0x00000000015d00ee in folly::detail::function::FunctionTraits<void ()>::operator()() (this=0x7fb22c63b1f0) at folly/Function.h:416
#20 folly::EventBase::FunctionLoopCallback::runLoopCallback (this=0x7fb22c63b1c0) at folly/io/async/EventBase.h:188
#21 folly::EventBase::runLoopCallbacks (this=<optimized out>) at folly/io/async/EventBase.cpp:703
#22 folly::EventBase::loopBody (this=0x7fb23ecb9410, flags=1, ignoreKeepAlive=false) at folly/io/async/EventBase.cpp:402
#23 0x00000000015cdc60 in folly::EventBase::loopOnce (this=0x7fb23ecb9410, flags=0) at folly/io/async/EventBase.cpp:330
#24 folly::EventBase::~EventBase (this=0x7fb23ecb9410, vtt=<optimized out>) at folly/io/async/EventBase.cpp:211
#25 0x00000000006f284e in openr::KvStore::~KvStore (this=0x7fb23ecb9400) at openr/kvstore/KvStore.h:532
```

To fix this, we introduced map to hold every individual future from thrift client. However, this occasionally will make KvStore destruction stuck when waiting for all futures to be fulfilled.

We should NOT track every individual future, which is NOT necessary at all.

From the crash trace, clearly, we are doing `mergePublications()` when invoking `processThriftPublication()` before checking if the peer is valid or NOT.

Fix:
Ignore the rest logic of callback `processThriftPublication()` if peerName is NOT valid.

Reviewed By: saifhhasan

Differential Revision: D24262710

fbshipit-source-id: fa69aaa5c6e43cfc861de7431b9c1e26195684a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant