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

fix multithreading bug about default_io in iiod-reader #1212

Open
wants to merge 38 commits into
base: main
Choose a base branch
from

Conversation

catkira
Copy link
Contributor

@catkira catkira commented Nov 6, 2024

PR Description

fixes #1211

PR Type

  • Bug fix (a change that fixes an issue)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have commented new code, particulary complex or unclear areas
  • I have checked that I did not intoduced new warnings or errors (CI output)
  • I have checked that components that use libiio did not get broken

@catkira catkira marked this pull request as draft November 6, 2024 15:30
@catkira catkira marked this pull request as ready for review November 7, 2024 18:07
@catkira catkira changed the title Fix a bug when adding new iiod_io elements to the reader list fix multithreading bug about default_io in iiod-reader Nov 7, 2024
…erted twice into the readers list.

This is only a temporary solution until the underlying issue is solved.
@cristina-suteu
Copy link
Collaborator

Hello. Can you please do a rebase/ clean up of the commits? It is a little unclear what's going on

@catkira
Copy link
Contributor Author

catkira commented Nov 25, 2024

There is no definitve fix yet. You can follow our discussion in the issue.

@nunojsa
Copy link
Contributor

nunojsa commented Nov 25, 2024

There is no definitve fix yet. You can follow our discussion in the issue.

I think the fix will be in line with serializing accesses to the default IO. I did implemented a possible fix but then I was pulled to some other stuff. I just pushed it here:

https://github.com/analogdevicesinc/libiio/tree/staging/multiple-default-io-users

If you time to look at it and give it a test... But this is totally untested code and it's likely to fail so totally fair if you don't want to try it 😅 . It's based on Paul's approach but it goes a step beyond with respect to refcounting. I think we have a fundamental issue in the client side with iiod_responder_get_default_io(). That gives us a pointer to a refcounted object but we do not increase the count. Adding that we have async waiting, we're opening a door for use after free (theoretical but I think possible). I'm also using the refcount value to detect whether or not the IO has active waiters.

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

Successfully merging this pull request may close these issues.

iio_buffer_destroy() sometimes hangs when items are enqueued
3 participants