You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "BewareMyPower (via GitHub)" <gi...@apache.org> on 2025/06/23 08:54:11 UTC

[I] [Bug] std::cout will cause segmentation fault with libpulsar linked [pulsar-client-cpp]

BewareMyPower opened a new issue, #494:
URL: https://github.com/apache/pulsar-client-cpp/issues/494

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/pulsar-client-cpp/issues) and found nothing similar.
   
   
   ### Version
   
   Client 3.7.1
   
   ### Minimal reproduce step
   
   Run a `rockylinux:9` container.
   
   ```bash
   yum update -y
   yum install gcc gcc-c++ curl
   curl -O -L https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.7.1/rpm-arm64/aarch64/apache-pulsar-client-3.7.1-1.aarch64.rpm
   curl -O -L https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.7.1/rpm-arm64/aarch64/apache-pulsar-client-devel-3.7.1-1.aarch64.rpm
   rpm -ivh apache-pulsar-client-*
   ```
   
   After installing the library with the commands above, build the following source file:
   
   ```c++
   #include <pulsar/Client.h>
   #include <iostream>
   
   int main() {
       std::cout << "hello" << std::endl;
   }
   ```
   
   It works well without linking to libpulsar:
   
   ```bash
   $ g++ main.cc 
   $ ./a.out 
   hello
   ```
   
   But it will encounter segmentation fault after linking to libpulsar:
   
   ```bash
   $ g++ main.cc -lpulsar
   $ ./a.out 
   Segmentation fault
   ```
   
   ### What did you expect to see?
   
   No segfault
   
   ### What did you see instead?
   
   Segfault
   
   ### Anything else?
   
   The regression should be introduced by https://github.com/apache/pulsar-client-cpp/pull/428, which adds static linking to libstdc++ and libgcc_s to the dynamic library for RPM and DEB packages.
   
   GDB shows the following stacks:
   
   ```
   #0  0x0000fffff7a58490 in std::basic_ostream<char, std::char_traits<char> >::sentry::sentry(std::basic_ostream<char, std::char_traits<char> >&) () from /lib/libpulsar.so
   #1  0x0000fffff7a58c1c in std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) () from /lib/libpulsar.so
   #2  0x0000fffff7a59100 in std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) () from /lib/libpulsar.so
   #3  0x0000000000400a20 in main () at main.cc:5
   ```
   
   The reason is that there are conflicts from two duplicated symbols. One is the statically linked libstdc++ in `libpulsar.so`, the other is the dynamically linked libstdc++ to the system's library.
   
   ```bash
   $ ldd a.out 
   	libpulsar.so => /lib/libpulsar.so (0x0000ffff93400000)
   	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x0000ffff93000000)
           ...
   ```
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] std::cout will cause segmentation fault with libpulsar linked [pulsar-client-cpp]

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower closed issue #494: [Bug] std::cout will cause segmentation fault with libpulsar linked
URL: https://github.com/apache/pulsar-client-cpp/issues/494


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org