You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered a problem when using mosquitto_lib_init in my code. To give you some context: I created a separate thread to handle MQTT operations, including initialization, connection, and publishing. I initiate the MQTT client using mosquitto_lib_init, and after a successful connection, I call mosquitto_loop_start. Importantly, there are no other threads to operate it.
When running the code, I encountered the following issue, as identified through gdb:
#0 0x76fd7580 in pthread_rwlock_trywrlock () from /lib/ld-musl-arm.so.1
#1 0x76fd7430 in pthread_rwlock_timedwrlock () from /lib/ld-musl-arm.so.1
#2 0x76ebee00 in CRYPTO_STATIC_MUTEX_lock_write () from /usr/lib/libcrypto.so
#3 0x76e66bd0 in CRYPTO_get_ex_new_index () from /usr/lib/libcrypto.so
#4 0x76f438a4 in net__init () at /home/xxxx/Work/workspace/cross_dynamiclink_lib_src/mosquitto/lib/net_mosq.c:149
#5 0x76f417cc in mosquitto_lib_init () at /home/xxxx/Work/workspace/cross_dynamiclink_lib_src/mosquitto/lib/mosquitto.c:77
#6 0x54f78aa8 in xx::module::ModuleMqttTsp::Start() ()
#7 0x54f455c4 in void std::_Mem_fn_base<void (xx::module::ModuleMqttTsp::*)(), true>::operator()<, void>(xx::module::ModuleMqttTsp*) const ()
#8 0x54f45258 in void std::_Bind_simple<std::_Mem_fn<void (xx::module::ModuleMqttTsp::*)()> (xx::module::ModuleMqttTsp*)>::_M_invoke<0u>(std::_Index_tuple<0u>) ()
#9 0x54f44fc0 in std::_Bind_simple<std::_Mem_fn<void (xx::module::ModuleMqttTsp::*)()> (xx::module::ModuleMqttTsp*)>::operator()() ()
#10 0x54f44df0 in std::thread::_Impl<std::_Bind_simple<std::_Mem_fn<void (xx::module::ModuleMqttTsp::*)()> (xx::module::ModuleMqttTsp*)> >::_M_run() ()
#11 0x76c432fc in ?? () from /usr/lib/libstdc++.so.6
Cannot access memory at address 0x7d0f00
Upon inspecting the mosquitto.h documentation, I found the following hint:
* If your application uses threads you must use <mosquitto_threaded_set> to
* tell the library this is the case, otherwise it makes some optimisations
* for the single threaded case that may result in unexpected behaviour for
* the multi threaded case.
I should mention that even though my application operates in a multi-threaded environment, I only have one thread interacting with the MQTT client. Therefore, it appears that using mosquitto_lib_init is not incorrect in my scenario.
However, I experimented with an alternative approach in my code:
Surprisingly, this modification resulted in successful execution without any errors. Although there is currently a problem that the server cannot receive it in publish, I think this is my own problem.
I could not find any relevant entries in the ChangeLog.txt regarding changes to mosquitto_lib_init in subsequent versions of the library. Therefore, I am seeking your assistance in understanding why this problem occurred and whether my modification is the correct solution.
Thank you very much for your support!
Bye
KudoWu
The text was updated successfully, but these errors were encountered:
Hello,
First, let me provide you with information about my operating environment:
I encountered a problem when using
mosquitto_lib_init
in my code. To give you some context: I created a separate thread to handle MQTT operations, including initialization, connection, and publishing. I initiate the MQTT client usingmosquitto_lib_init
, and after a successful connection, I call mosquitto_loop_start. Importantly, there are no other threads to operate it.When running the code, I encountered the following issue, as identified through gdb:
Upon inspecting the mosquitto.h documentation, I found the following hint:
I should mention that even though my application operates in a multi-threaded environment, I only have one thread interacting with the MQTT client. Therefore, it appears that using mosquitto_lib_init is not incorrect in my scenario.
However, I experimented with an alternative approach in my code:
Surprisingly, this modification resulted in successful execution without any errors. Although there is currently a problem that the server cannot receive it in publish, I think this is my own problem.
I could not find any relevant entries in the ChangeLog.txt regarding changes to
mosquitto_lib_init
in subsequent versions of the library. Therefore, I am seeking your assistance in understanding why this problem occurred and whether my modification is the correct solution.Thank you very much for your support!
Bye
KudoWu
The text was updated successfully, but these errors were encountered: