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

Compiler issue of multiple definition with libfolly.a and libstdc++.a #4072

Closed
Sean58238 opened this issue Mar 23, 2022 · 4 comments
Closed
Assignees
Labels
community Source: who proposed the issue type/bug Type: something is unexpected wontfix Solution: this will not be worked on recently
Milestone

Comments

@Sean58238
Copy link

A compiler issue of multiple definition with libfolly.a and libstdc++.a as following
[ 69%] Building CXX object src/meta/CMakeFiles/meta_service_handler.dir/processors/schema/CreateEdgeProcessor.cpp.o
/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a(eh_catch.o): In function __cxa_begin_catch': (.text.__cxa_begin_catch+0x0): multiple definition of __cxa_begin_catch'
/home/sean/nebula/nebula/build/third-party/install/lib/libfolly.a(ExceptionTracerLib.cpp.o):(.text+0x2030): first defined here
/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a(eh_catch.o): In function __cxa_end_catch': (.text.__cxa_end_catch+0x0): multiple definition of __cxa_end_catch'
/home/sean/nebula/nebula/build/third-party/install/lib/libfolly.a(ExceptionTracerLib.cpp.o):(.text+0x1e60): first defined here
/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a(eh_ptr.o): In function std::rethrow_exception(std::__exception_ptr::exception_ptr)': (.text._ZSt17rethrow_exceptionNSt15__exception_ptr13exception_ptrE+0x0): multiple definition of std::rethrow_exception(std::__exception_ptr::exception_ptr)'
/home/sean/nebula/nebula/build/third-party/install/lib/libfolly.a(ExceptionTracerLib.cpp.o):(.text+0x1c60): first defined here
/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a(eh_throw.o): In function __cxa_throw': (.text.__cxa_throw+0x0): multiple definition of __cxa_throw'
/home/sean/nebula/nebula/build/third-party/install/lib/libfolly.a(ExceptionTracerLib.cpp.o):(.text+0x1990): first defined here
/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.a(eh_throw.o): In function __cxa_rethrow': (.text.__cxa_rethrow+0x0): multiple definition of __cxa_rethrow'
/home/sean/nebula/nebula/build/third-party/install/lib/libfolly.a(ExceptionTracerLib.cpp.o):(.text+0x1b40): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [src/daemons/CMakeFiles/nebula-storaged.dir/build.make:634: bin/nebula-storaged] Error 1
make[1]: *** [CMakeFiles/Makefile2:6625: src/daemons/CMakeFiles/nebula-storaged.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

**Your Environments **

  • OS: CentOS Linux release 8.5.2111
  • Kernel: Linux inspur01 5.4.32 Test failure in NetworkUtilsTest #9 SMP Thu Sep 24 12:22:25 CST 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Compiler: g++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4)
  • cmake version 3.20.2
  • CPU: Intel(R) Xeon(R) Platinum 8358 CPU @ 2.60GHz
  • Commit id : 2e938c7 (HEAD -> v3.0.1, tag: v3.0.1, origin/v3.0.1)

Steps to reproduce the behavior:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/nebula -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release ..
make -j

@Sean58238 Sean58238 added the type/bug Type: something is unexpected label Mar 23, 2022
@Sophie-Xie Sophie-Xie added this to the v3.1.0 milestone Mar 23, 2022
@Sean58238
Copy link
Author

Any comments for this?

@wey-gu
Copy link
Contributor

wey-gu commented Mar 25, 2022

Dear @Sean58238
@yixinglu was assigned to look into this.

@wey-gu
Copy link
Contributor

wey-gu commented Mar 25, 2022

Below is my person note on build/debug from the nebula-dev container, with which, we could have build utilit/dep in isolated manner and can be used out of box, could you try with this instead, first?

I used this container as a long run one, and it's pretty handy for me.

Developing Env Setup

Nebula Graph assumed to be developed in GNU/Linux OS. The fastest yet clean way would be leveraging container(Docker, nerdctl, Podman etc...). Let's take docker as an example:

First, clone the code and change to its path, and assuming we are working on v3.0.0 tag:

git clone git@github.com:vesoft-inc/nebula.git
cd nebula
git checkout v3.0.0

Then, let's create a long-run Dev Container named nebula_<your_username>

# we create a docker network to enable future debugging on a Docker-Compose based Cluster
docker network create -d bridge nebula-docker-compose_nebula-net

export TAG=ubuntu2004
docker run -ti \
  --network nebula-docker-compose_nebula-net \
  --security-opt seccomp=unconfined \
  -v "$PWD":/home/nebula \
  -w /home/nebula \
  --name nebula_$USER \
  vesoft/nebula-dev:$TAG \
  bash

# exit

Everytime you would like to access it, just:

docker start nebula_$USER
docker exec -ti nebula_$USER bash

Build the source for the first time, note the first time build will take up to several hours.

# access to dev docker if not yet
docker exec -ti nebula_$USER bash

mkdir build && cd build

cmake -DCMAKE_CXX_COMPILER=$TOOLSET_CLANG_DIR/bin/g++ -DCMAKE_C_COMPILER=$TOOLSET_CLANG_DIR/bin/gcc -DENABLE_WERROR=OFF -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTING=OFF ..

make -j64 # change 64 according to your cpu number
make install

Check the built binaries, and nebula home:

root@1827b82e88bf:/home/nebula/build# ls /usr/local/nebula/bin
db_dump  db_upgrader  meta_dump  nebula-graphd  nebula-metad  nebula-storaged

root@1827b82e88bf:/home/nebula/build# ls /usr/local/nebula/
bin  etc  pids  scripts  share

Debug Nebula Graph

This is an example on graphd.

Let's assume we are working on the v3.0.0 Nebula Graph, otherwise, for example if it's the master branch, change to master according.

Setup a Nebula Cluster

Run a Nebula Graph Cluster with Docker Compose:

git clone -b v3.0.0 https://github.com/vesoft-inc/nebula-docker-compose.git
cd nebula-docker-compose/
docker-compose up -d

Access to the cluster and Activate Storage Services with ADD HOSTS

docker run --rm -ti \
  --network nebula-docker-compose_nebula-net \
  --entrypoint=/bin/sh vesoft/nebula-console:v3.0.0

# Now we are in nebula-console(graphd CLI client) container
nebula-console -u root -p nebula --address=graphd --port=9669

# Now we are in nebula-conosle propmt
SHOW HOSTS;
ADD HOSTS "storaged0":9779,"storaged1":9779,"storaged2":9779;
SHOW HOSTS;

Load the basketballplayer dataset into Nebula Graph from nebula-console

:play basketballplayer;

# Dont panic, it will hang there for 1 minute to load them all.
# You will see somthing like this:
(root@nebula) [(none)]> :play basketballplayer;
Start loading dataset basketballplayer...

Load dataset succeeded!

Exist the Console

# exit the console prompt
exit

# exit the console container if you like to, you can stay here as you will come back soon.
exit

Run a graphd with gdb

Note, here we need to take note of your Dev Container Name, let's say, your username is tom, then you should have it as nebula_tom, from here I assumed we have it as nebula_tom.

Access the nebula_tom container

docker exec -ti nebula_$USER bash

Access the gdb

cd /usr/local/nebula/
mkdir -p /home/nebula/build/log
gdb bin/nebula-graphd

Set gdb variables, plese be noted, the nebula_tom below should be replaced with your container name accordingly!

set follow-fork-mode child
set args --flagfile=/usr/local/nebula/etc/nebula-graphd.conf.default \
    --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 \
    --port=9669 \
    --local_ip=nebula_tom \
    --ws_ip=nebula_tom \
    --ws_http_port=19669 \
    --log_dir=/home/nebula/build/log \
    --v=0 \
    --minloglevel=0 

Set a break function you would like to debug, here I will make it stop at the function: VertexIdSeek::matchNode

Then I will give

b VidExtractVisitor::visit

Then we could give a run to let the graphD running on nebula_tom in the docker network nebula-docker-compose_nebula-net, conneted to our existing Nebula Cluster.

Connecting to the graphd running via gdb

Access to the nebula-console container

docker run --rm -ti \
  --network nebula-docker-compose_nebula-net \
  --entrypoint=/bin/sh vesoft/nebula-console:v3.0.0

Run the console CLI binary, replace the nebula_tom part to your dev container name

nebula-console -u root -p nebula --address=nebula_tom --port=9669

Check graph hosts:

> SHOW HOSTS GRAPH;
+--------------+------+-----------+---------+--------------+----------+
| Host         | Port | Status    | Role    | Git Info Sha | Version  |
+--------------+------+-----------+---------+--------------+----------+
| "graphd"     | 9669 | "ONLINE"  | "GRAPH" | "02b2091"    | "v3.0.0" |
| "graphd"     | 9669 | "ONLINE"  | "GRAPH" | "02b2091"    | "v3.0.0" |
| "graphd"     | 9669 | "ONLINE"  | "GRAPH" | "02b2091"    | "v3.0.0" |
| "nebula_tom" | 9669 | "ONLINE"  | "GRAPH" | "02b2091"    | "v3.0.0" |
+--------------+------+-----------+---------+--------------+----------+

Give a query that may hit our breaking point, it should hang there.

> MATCH (n) WHERE id(n) == "player100" RETURN n;

Debug from GDB

Let's back to the GDB window:

(gdb)

Below is an example of GDB.

# f means to see current line
(gdb) f
#0  nebula::graph::VidExtractVisitor::visit (this=0x7fffd4df3800, expr=0x7fffd421ba00) at /home/nebula/src/graph/visitor/VidExtractVisitor.cpp:218
218	}

# l means to list surrounding code
(gdb) l
213	                               {{"", {VidPattern::Vids::Kind::kOtherSource, {}}}}};
214	    } else {
215	      vidPattern_ = VidPattern{};
216	    }
217	  }
218	}
219
220	void VidExtractVisitor::visit(SubscriptExpression *expr) {
221	  UNUSED(expr);
222	  vidPattern_ = VidPattern{};

# print variables of current scope
(gdb) print vidPattern_
$7 = {spec = nebula::graph::VidExtractVisitor::VidPattern::Special::kIgnore, nodes = {
    _M_h = {<std::__detail::_Hashtable_base<std::__cxx11::basic_string<char, 

...

# bt to query backtrace!
(gdb) bt
#0  nebula::graph::VidExtractVisitor::visit (this=0x7fffd4df3800, expr=0x7fffd421ba00) at /home/nebula/src/graph/visitor/VidExtractVisitor.cpp:218
#1  0x0000000004903272 in nebula::RelationalExpression::accept (this=0x7fffd421ba00, visitor=0x7fffd4df3800) at /home/nebula/src/common/expression/RelationalExpression.cpp:260
#2  0x0000000003568be2 in nebula::graph::VertexIdSeek::matchNode (this=0x7fffd42070a8, nodeCtx=0x7fffd4df3970) at /home/nebula/src/graph/planner/match/VertexIdSeek.cpp:40
#3  0x0000000003566957 in nebula::graph::StartVidFinder::match (this=0x7fffd42070a8, patternCtx=0x7fffd4df3970) at /home/nebula/src/graph/planner/match/StartVidFinder.cpp:13
...

# n to execute next line
(gdb) n
nebula::RelationalExpression::accept (this=0x7fffd421ba00, visitor=0x7fffd4df3800) at /home/nebula/src/common/expression/RelationalExpression.cpp:261
261	}

# s to step in a forloop or a function

(gdb)
# c to continue until next break point

Changing code

Modify the code

Let's say we are changing code, we actually just do it with your beloved editor inside the repo path, and it's not necessary to access the Dev Container.

Build and Debug again

Build

To build on changed code base, we should access the container

docker exec -ti nebula_$USER bash
# in the dev container
source /opt/vesoft/toolset/gcc/9.3.0/enable
cd build

option: build and debug with unit test, note, this will consume more RAM:

cmake -DCMAKE_CXX_COMPILER=$TOOLSET_CLANG_DIR/bin/g++ -DCMAKE_C_COMPILER=$TOOLSET_CLANG_DIR/bin/gcc -DENABLE_WERROR=OFF -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTING=ON ..
make -j64 # change 64 to other values based on your machine CPU count

option: build without unit test:

cmake -DCMAKE_CXX_COMPILER=$TOOLSET_CLANG_DIR/bin/g++ -DCMAKE_C_COMPILER=$TOOLSET_CLANG_DIR/bin/gcc -DENABLE_WERROR=OFF -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTING=OFF ..
make -j64

Debug with GDB

Let's take graphd as an example, it's exactly the same as above chapters before changing code, nebula_tom as assumed as the container name, please change accordingly:

docker exec -ti nebula_$USER bash
cd /usr/local/nebula/
mkdir -p /home/nebula/build/log
gdb bin/nebula-graphd
set follow-fork-mode child
set args --flagfile=/usr/local/nebula/etc/nebula-graphd.conf.default \
    --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 \
    --port=9669 \
    --local_ip=nebula_tom \
    --ws_ip=nebula_tom \
    --ws_http_port=19669 \
    --log_dir=/home/nebula/build/log \
    --v=0 \
    --minloglevel=0 
b VidExtractVisitor::visit
run

@Sophie-Xie Sophie-Xie added wontfix Solution: this will not be worked on recently community Source: who proposed the issue labels Apr 11, 2022
@Sophie-Xie Sophie-Xie modified the milestones: v3.1.0, v3.2.0 Apr 24, 2022
@Sophie-Xie
Copy link
Contributor

Pls update latest third party lib.
https://docs.nebula-graph.com.cn/3.0.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/1.install-nebula-graph-by-compiling-the-source-code/

If if it still doesn't work, we continue to discuss it. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Source: who proposed the issue type/bug Type: something is unexpected wontfix Solution: this will not be worked on recently
Projects
None yet
Development

No branches or pull requests

4 participants