I am developing a small application that uses the azure iot sdk in C (lts_07_2021). All my test cases worked well except for one that is related to the proxy. When providing a working/correct proxy server information, my application successfully connected without any problems. But when I provided a non-working proxy information, it produces a segfault. I expected that the SDK will provide some sort of error message but not the segfault.
It can also be reproduced using the example provided by azure in azure-iot-sdk-c/iothub_client/samples/iothub_ll_telemetry_sample I just added the following options:
HTTP_PROXY_OPTIONS proxy;
memset(&proxy, 0, sizeof(HTTP_PROXY_OPTIONS));
proxy.host_address = "x.x.x.x"; //non-working proxy server
proxy.port = 3128;
(void)IoTHubDeviceClient_LL_SetOption(device_ll_handle, OPTION_HTTP_PROXY,&proxy);
Heres the terminal output when running iothub_ll_telemetry_sample provided by azure + INCORRECT PROXY: https://github.com/Azure/azure-iot-sdk-c/blob/lts_07_2021/iothub_client/samples/iothub_ll_telemetry_sample/iothub_ll_telemetry_sample.c
[iothub_ll_telemetry_sample]$ ./iothub_ll_telemetry_sample
Creating IoTHub Device handle
Sending message 1 to IoTHub
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/adapters/socketio_berkeley.c Func:wait_for_connection Line:415 Failure: select failure.
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/adapters/socketio_berkeley.c Func:socketio_open Line:833 wait_for_connection failed
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/src/http_proxy_io.c Func:on_underlying_io_open_complete Line:280 Underlying IO open failed
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/umqtt/src/mqtt_client.c Func:onOpenComplete Line:454 Error: failure opening connection to endpoint
The device client has been disconnected
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/adapters/tlsio_openssl.c Func:on_underlying_io_open_complete Line:849 Invalid tlsio_state. Expected state is TLSIO_STATE_OPENING_UNDERLYING_IO.
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/src/http_proxy_io.c Func:http_proxy_io_open Line:749 Cannot open the underlying IO.
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/adapters/tlsio_openssl.c Func:tlsio_openssl_open Line:1437 Failed opening the underlying I/O.
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/src/uws_client.c Func:uws_client_open_async Line:1700 Opening the underlying IO failed
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/c-utility/src/wsio.c Func:wsio_open Line:519 Opening the uws instance failed.
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/umqtt/src/mqtt_client.c Func:mqtt_client_connect Line:1118 Error: io_open failed
Error: Time:Tue Feb 8 13:14:51 2022 File:/isolated/azure-iot-sdk-c/iothub_client/src/iothubtransport_mqtt_common.c Func:SendMqttConnectMsg Line:2696 failure connecting to address xxxxxxxxxx.azure-devices.net.
Sending message 2 to IoTHub
Segmentation fault (core dumped)
Here's the backtrace: It seems like the stack frames goes on and on... repeating
#0 0x00000000004383c7 in OptionHandler_Destroy ()
#1 0x00000000004403c1 in http_proxy_io_destroy_option ()
#2 0x0000000000437ea3 in DestroyInternal ()
#3 0x00000000004383cc in OptionHandler_Destroy ()
#4 0x00000000004403c1 in http_proxy_io_destroy_option ()
#5 0x0000000000437ea3 in DestroyInternal ()
#6 0x00000000004383cc in OptionHandler_Destroy ()
#7 0x00000000004403c1 in http_proxy_io_destroy_option ()
#8 0x0000000000437ea3 in DestroyInternal ()
#9 0x00000000004383cc in OptionHandler_Destroy ()
#10 0x00000000004403c1 in http_proxy_io_destroy_option ()
#11 0x0000000000437ea3 in DestroyInternal ()
#12 0x00000000004383cc in OptionHandler_Destroy ()
#13 0x00000000004403c1 in http_proxy_io_destroy_option ()
#14 0x0000000000437ea3 in DestroyInternal ()
#15 0x00000000004383cc in OptionHandler_Destroy ()
#16 0x00000000004403c1 in http_proxy_io_destroy_option ()
#17 0x0000000000437ea3 in DestroyInternal ()
#18 0x00000000004383cc in OptionHandler_Destroy ()
#19 0x00000000004403c1 in http_proxy_io_destroy_option ()
#20 0x0000000000437ea3 in DestroyInternal ()
#21 0x00000000004383cc in OptionHandler_Destroy ()
#22 0x00000000004403c1 in http_proxy_io_destroy_option ()
#23 0x0000000000437ea3 in DestroyInternal ()
#24 0x00000000004383cc in OptionHandler_Destroy ()
#25 0x00000000004403c1 in http_proxy_io_destroy_option ()
#26 0x0000000000437ea3 in DestroyInternal ()
#27 0x00000000004383cc in OptionHandler_Destroy ()
#28 0x00000000004403c1 in http_proxy_io_destroy_option ()
#29 0x0000000000437ea3 in DestroyInternal ()
#30 0x00000000004383cc in OptionHandler_Destroy ()
#31 0x00000000004403c1 in http_proxy_io_destroy_option ()
#32 0x0000000000437ea3 in DestroyInternal ()
#33 0x00000000004383cc in OptionHandler_Destroy ()
#34 0x00000000004403c1 in http_proxy_io_destroy_option ()
#35 0x0000000000437ea3 in DestroyInternal ()
#36 0x00000000004383cc in OptionHandler_Destroy ()
#37 0x00000000004403c1 in http_proxy_io_destroy_option ()
#38 0x0000000000437ea3 in DestroyInternal ()
#39 0x00000000004383cc in OptionHandler_Destroy ()
#40 0x00000000004403c1 in http_proxy_io_destroy_option ()
#41 0x0000000000437ea3 in DestroyInternal ()
#42 0x00000000004383cc in OptionHandler_Destroy ()
#43 0x00000000004403c1 in http_proxy_io_destroy_option ()
#44 0x0000000000437ea3 in DestroyInternal ()
#45 0x00000000004383cc in OptionHandler_Destroy ()
#46 0x00000000004403c1 in http_proxy_io_destroy_option ()
#47 0x0000000000437ea3 in DestroyInternal ()
#48 0x00000000004383cc in OptionHandler_Destroy ()
#49 0x00000000004403c1 in http_proxy_io_destroy_option ()
#50 0x0000000000437ea3 in DestroyInternal ()
#51 0x00000000004383cc in OptionHandler_Destroy ()
#52 0x00000000004403c1 in http_proxy_io_destroy_option ()
#53 0x0000000000437ea3 in DestroyInternal ()
#54 0x00000000004383cc in OptionHandler_Destroy ()
#55 0x00000000004403c1 in http_proxy_io_destroy_option ()
.
.
.
.
.
.#xxxxx repeatedly goes on and on
System information: CentOS-7 cURL7.29 openssl1.0.2k