You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "haolujun (via GitHub)" <gi...@apache.org> on 2023/04/10 12:11:45 UTC
[GitHub] [pulsar-client-cpp] haolujun opened a new issue, #248: logging thread_local error when thread exit [Bug]
haolujun opened a new issue, #248:
URL: https://github.com/apache/pulsar-client-cpp/issues/248
### Search before asking
- [X] I searched in the [issues](https://github.com/apache/pulsar-client-cpp/issues) and found nothing similar.
### Version
all version. because I saw that threadSpecificLogPtr in all version code.
### Minimal reproduce step
May be use a static client.
### What did you expect to see?
Do not have crash!
### What did you see instead?
when thread exit and client destory, I called client.close() to close the connection. But, got a crash!. I saw the code and added some debug printf, finally I found that, threadSpecificLogPtr in ./lib/LogUtils.h is destoryed before client close, but thread_local ptr is not null. And then client close and may be use threadSpecificLogPtr to log, and at this time got a pointer that has been destroyed. The destroyed order of client and threadSpecificLogPtr is not correct. Hope the solution!
### Anything else?
_No response_
### 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
[GitHub] [pulsar-client-cpp] BewareMyPower commented on issue #248: logging thread_local error when thread exit [Bug]
Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on issue #248:
URL: https://github.com/apache/pulsar-client-cpp/issues/248#issuecomment-1503406941
It's not a bug related to pybind11. I've also seen similar errors with other languages like PHP. We have to handle the logger destruction carefully if the C++ library is loaded by an external application (e.g. the Python interpreter).
--
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
[GitHub] [pulsar-client-cpp] haolujun commented on issue #248: logging thread_local error when thread exit [Bug]
Posted by "haolujun (via GitHub)" <gi...@apache.org>.
haolujun commented on issue #248:
URL: https://github.com/apache/pulsar-client-cpp/issues/248#issuecomment-1502642939
The Code like bellow:
`
class OuterClient {
public:
OuterClient(const std::string& service_url) : client_(service_url) {}
~OuterClient() {
client_.close(); //may core
}
pulsar::Client client_;
};
std::unique_ptr<OuterClient> client;
int main() {
client.reset(new OuterClient("xxxx"));
return 0;
}
`
--
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
[GitHub] [pulsar-client-cpp] haolujun commented on issue #248: logging thread_local error when thread exit [Bug]
Posted by "haolujun (via GitHub)" <gi...@apache.org>.
haolujun commented on issue #248:
URL: https://github.com/apache/pulsar-client-cpp/issues/248#issuecomment-1503237248
Thanks! After some debug, I had found the reason why I got a crash! Because I used pybind in my program, and when pybind thread exit, pybind may be cause the wrong order of object destruction, I think this is pybind bug. After I add some destroy code in _cleanup(pybind support user to define what should do when pybind exit), and got a correct destruction order.
--
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
[GitHub] [pulsar-client-cpp] haolujun commented on issue #248: logging thread_local error when thread exit [Bug]
Posted by "haolujun (via GitHub)" <gi...@apache.org>.
haolujun commented on issue #248:
URL: https://github.com/apache/pulsar-client-cpp/issues/248#issuecomment-1505136325
@BewareMyPower Thanks!
--
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
[GitHub] [pulsar-client-cpp] BewareMyPower commented on issue #248: logging thread_local error when thread exit [Bug]
Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on issue #248:
URL: https://github.com/apache/pulsar-client-cpp/issues/248#issuecomment-1502743418
I cannot reproduce this issue with the following code:
```c++
#include <pulsar/Client.h>
using namespace pulsar;
class OuterClient {
public:
OuterClient(const std::string& service_url) : client_(service_url) {}
~OuterClient() { client_.close(); }
private:
Client client_;
};
std::unique_ptr<OuterClient> client;
int main() {
client.reset(new OuterClient("pulsar://localhost:6650"));
return 0;
}
```
--
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
[GitHub] [pulsar-client-cpp] haolujun closed issue #248: logging thread_local error when thread exit [Bug]
Posted by "haolujun (via GitHub)" <gi...@apache.org>.
haolujun closed issue #248: logging thread_local error when thread exit [Bug]
URL: https://github.com/apache/pulsar-client-cpp/issues/248
--
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