Skip to content
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

Upload error for empty blob on MQTT #2392

Closed
opekhovskiy-zf opened this issue Oct 19, 2022 · 2 comments
Closed

Upload error for empty blob on MQTT #2392

opekhovskiy-zf opened this issue Oct 19, 2022 · 2 comments
Assignees
Labels

Comments

@opekhovskiy-zf
Copy link

Development Machine, OS, Compiler (and Other Relevant Toolchain Info)

Ubuntu 22.04.1 LTS
gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0

SDK Version

1.9.1
Commit SHA: 3fd808b
Release 2022-09-19

Protocol

MQTT

Describe the Bug

Sending zero size blob with IoTHubDeviceClient_UploadMultipleBlocksToBlobAsync function leads to
underfined behavior in most cases causing FILE_UPLOAD_ERROR.
The main reason is that variable httpResponse defined in IoTHubClient_LL_UploadMultipleBlocksToBlob_Impl
left uninitialized after the call of Blob_UploadMultipleBlocksFromSasUri.
This is because when source == NULL || size == 0 (which is our case) variable httpStatus
(which is the pointer to the outer httpResponse) is never used.
The patch 01-empty-blob-http-status-fix.patch just adds *httpStatus = 200.

Here is how call stack looks in this case:
InvokeUserCallbackAndSendBlobs blob.c:209
Blob_UploadMultipleBlocksFromSasUri blob.c:347
IoTHubClient_LL_UploadMultipleBlocksToBlob_Impl iothub_client_ll_uploadtoblob.c:742
IoTHubClientCore_LL_UploadMultipleBlocksToBlobEx iothub_client_core_ll.c:2770
uploadMultipleBlock_thread iothub_client_core.c:2437
ThreadWrapper threadapi_pthreads.c:35
start_thread 0x00007ffff6aefb43
clone3 0x00007ffff6b81a00

MCVE

Please use example attached
azure_empty_blob_test.zip

Console Logs

$ ./test
Test started!
SDK version: 1.9.1
-> 22:18:07 CONNECT | VER: 4 | KEEPALIVE: 120 | FLAGS: 192 | USERNAME: ares-iot-odc.azure-devices.net/7C9763504107/?api-version=2020-09-30&DeviceClientType=iothubclient%2f1.9.1%20(native%3b%20Linux%3b%20x86_64) | PWD: XXXX | CLEAN: 0
<- 22:18:07 CONNACK | SESSION_PRESENT: true | RETURN_CODE: 0x0
IOTHUB_CLIENT_CONNECTION_AUTHENTICATED: IOTHUB_CLIENT_CONNECTION_OK
-> 22:18:07 SUBSCRIBE | PACKET_ID: 2 | TOPIC_NAME: devices/7C9763504107/messages/devicebound/# | QOS: 1 | TOPIC_NAME: $iothub/twin/res/# | QOS: 0
Async upload empty1.txt for Blob #1
<- 22:18:07 SUBACK | PACKET_ID: 2 | RETURN_CODE: 1 | RETURN_CODE: 0
-> 22:18:07 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/GET/?$rid=3
<- 22:18:07 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/res/200/?$rid=3 | PAYLOAD_LEN: 2888
-> 22:18:07 SUBSCRIBE | PACKET_ID: 4 | TOPIC_NAME: $iothub/twin/PATCH/properties/desired/# | QOS: 0
<- 22:18:07 SUBACK | PACKET_ID: 4 | RETURN_CODE: 0
Sending Blob #1
Blob send OK
Async upload empty2.txt for Blob #2
Sending Blob #2
Blob send Error: FILE_UPLOAD_ERROR
Async upload empty3.txt for Blob #3
Sending Blob #3
Blob send Error: FILE_UPLOAD_ERROR
Async upload empty4.txt for Blob #4
Sending Blob #4
Blob send Error: FILE_UPLOAD_ERROR
Async upload empty5.txt for Blob #5
Sending Blob #5
Blob send Error: FILE_UPLOAD_ERROR
Async upload empty6.txt for Blob #6
Sending Blob #6
Blob send Error: FILE_UPLOAD_ERROR
Async upload empty7.txt for Blob #7
Sending Blob #7
Blob send Error: FILE_UPLOAD_ERROR
Async upload empty8.txt for Blob #8
Sending Blob #8
Blob send Error: FILE_UPLOAD_ERROR
Async upload empty9.txt for Blob #9
Sending Blob #9
Blob send Error: FILE_UPLOAD_ERROR
Async upload empty10.txt for Blob #10
-> 22:18:11 UNSUBSCRIBE | PACKET_ID: 5 | TOPIC_NAME: devices/7C9763504107/messages/devicebound/#
Sending Blob #10
Blob send Error: FILE_UPLOAD_ERROR
-> 22:18:11 DISCONNECT
Test finished!

@ericwolz
Copy link
Contributor

#2393

@ericwolz
Copy link
Contributor

Thanks for the submission. This issue has been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants