-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Bug] cpp client segmentation fault #17279
Comments
I found that when I use make_shared in ReportClient, the program will core, remove make_shared, it works fine |
@zhcn code doesn't render well. Could you wrap them inside a code block? |
ok |
can you see anything wrong? @tisonkun |
I use apache-pulsar-client-2.10.1-1.x86_64.rpm download from web, it also cause segment fault |
I see you used the RPM package and your G++ version is 7.
Could you try the default GCC (4.8.2)? |
Could you give a complete example? Your code cannot be compiled. I just downloaded the latest code in branch-2.11 and built the Pulsar C++ client from source. The following example works well. #include <pulsar/Client.h>
using namespace pulsar;
void func() {
auto t = std::make_shared<std::string>("");
std::cout << t << std::endl;
}
int main() {
func();
Client client("pulsar://localhost:6650");
std::string topic = "my-topic";
Producer producer;
auto result = client.createProducer(topic, producer);
if (result != ResultOk) {
std::cout << "Error creating producer: " << result << std::endl;
return 1;
}
MessageId messageId;
producer.send(MessageBuilder().setContent("hello").build(), messageId);
client.close();
return 0;
} Outputs:
The dependencies are:
I installed Protobuf 3.20.0 from source. The GCC version: $ g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
I also tried the 2.10.1 RPM package and it works well with GCC 4.8.
g++ SampleProducer.cc -std=c++11 -I /pulsar/pulsar-client-cpp/include -L /usr/lib -lpulsar
export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
./a.out Outputs:
I suspect there are multiple GCC compilers in your environment and you didn't set the related environment variables ( ldd <your-executable>
g++ --version I just remember a thing. The RPM package was compiled from GCC 4.8.5, i.e. when you use the library with a GCC >= 5, you must add the |
|
|
I use -D_GLIBCXX_USE_CXX11_ABI=0, it still get a segment fault
|
when I use gcc 4.8.5, it works fine, no segment fault |
so, should I compile pulsar client with gcc 7.3.1 to fix this problem? |
According to your $ ls -l /lib64/libstdc++.so.6
lrwxrwxrwx 1 root root 19 Nov 13 2020 /lib64/libstdc++.so.6 -> libstdc++.so.6.0.19 If you compiled your program with GCC 7, you must set the
Maybe not. You should link to the correct library when you ran it. Even if you compiled with GCC 7, if your executable still links to the |
Is libstdc++.so.6.0.24 belong to gcc7?
|
Yes. Maybe you can try building the library from source with GCC 7. |
when I use gcc7 to build pulsar client from source to build a rpm. I get a problem, and when I use gcc4.8 it can make rpm succ
|
Could you skip building RPM packages first? I think you can verify your |
I compile pulsar client use gcc7. but I get the following compile errors
|
You should use |
add -D_GLIBCXX_USE_CXX11_ABI=1 and it works fine
it maybe because my gcc is configured ,--with-default-libstdcxx-abi=gcc4-compatible
|
but I'm still confued, if my gcc is -with-default-libstdcxx-abi=gcc4-compatible, why compiled with pulsar client lib which compiled by gcc4.8 will segment fault? |
The segmentation fault might not be caused by the ABI compatibility, otherwise it should still failed in compile time, not runtime. I still suspect your compilation environment and runtime environment are not consistent, e.g. when it's compiled, it linked to GCC 7, when it's executed, it linked to GCC 4.8. |
so if I set my GCC 7 ABI gcc4-compatible, I must use GCC 4 libstdc++.so not GCC 7 libstdc++.so ? |
I didn't test that. But I think you can test the official C++ library in a pure environment like docker container. Then you can figure out if there is something wrong with your env. |
thanks alot for you help!@BewareMyPower |
closed |
###
Search before askingVersion
gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC)
pulsar cpp client version 2.11
Minimal reproduce step
What did you expect to see?
works
What did you see instead?
Anything else?
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: