buglwIP - A Lightweight TCP/IP stack - Bugs: bug #54528, MQTT Ring Buffer Gets Corrupted...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #54528: MQTT Ring Buffer Gets Corrupted under RTOS Operation

Submitter:  Richard I <richardi>
Submitted:  Fri 17 Aug 2018 02:00:11 PM UTC
   
 
Category:  apps Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Planned Release:  None
lwIP version:  2.0.2

Fri 17 Aug 2018 07:24:34 PM UTC, comment #2: 

That sounds like you're violating threading requirements.

Read the docs, e.g. http://www.nongnu.org/lwip/2_0_x/pitfalls.html

Simon Goldschmidt <goldsimon>
Group administrator
Fri 17 Aug 2018 02:29:45 PM UTC, comment #1: 

Oops, typo - the clashing context is meant to be mqtt_tcp_sent_cb(), which is invoked after a successful ACK of the prior packet and proceeds to spool the ringbuf, not the error callback...

Richard I <richardi>
Fri 17 Aug 2018 02:00:11 PM UTC, original submission:  

Hi, great job on the mqtt client - it's definitely one of the best implementations out there that is suitable for embedded use. During some stress testing using a high-volume publishing client, it occasionally crashes with Wireshark showing malformed MQTT messages prior to crash and subsequent broker disconnect. Reason for this is ring buffer corruption in mqtt_output_send(). This function is being called from two separate contexts - application context via mqtt_publish(), as well as from the tcp_ip thread via the mqtt_tcp_err_cb(). Occasionally both contexts clash, and the ring_buffer gets clobbered - there are a few places this can happen, but one obvious one is that calculated length is actually much less by the time the index gets advanced, so uninitialised data gets sent as a MQTT packet. Workaround for me was to wrap this function in a mutex, but my solution is FreeRTOS specific, so I'm unfortunately unable to assist with a pull request.

Richard I <richardi>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by richardi (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-17 goldsimon StatusNone Invalid
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code