Skip to content

tinyiio crashed when libiio refill was called on an empty tinyiio buffer. #2730

@kister-jimenez

Description

@kister-jimenez

My assumption with the READBUF or when a refill call from the host using libiio is if the circular buffer used to store samples with a trigger handler is empty or less than what was configured as buffer size in the host, it should just get an -EAGAIN. However, it crashed the tinyiio and looking at the code here,

ret = do_read_buff(desc, conn);
the -EAGAIN propagated to the iio_app instead of passing it to the conn->res.

Catching the -EAGAIN and preventing it from propagating to the calling functions solved the issue of crashing. But, libiio now returns a timeout when refill was called when circular buffer in tinyiio was empty, which is fine since we can just call the refill function with a backoff timer from the application. Is there a way to safely refill when tinyiio buffer is empty?

To replicate:

  1. You need an iio driver with a trigger handler (without .submit/read_rev ops) that fills the circullar buffer with samples. Use a large delay for example 5000ms per trigger. Set the number of samples pushed to 2 per trigger.
  2. You can create a very simple pyadi-iio (or maybe use iio cli toos) to get the buffer contents every 1 second. Set the buffer size to 2.
  3. If the interrupt started ahead of your .rx() call in pyadi-iio, you will get data until the buffer is empty and it will crash after a few timeouts and READ INTEGER and READLINE errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions