Skip to content

Conversation

@Watson1978
Copy link
Contributor

Fix #87

This patch will fix a race condition where Coolio_Loop_process_event attempts to process an event for a watcher that has already been detached.

When detach is called (e.g., from another thread or a preceding callback in the same loop cycle), the watcher's loop reference is cleared to nil.
If an event for this watcher was already pending in the libev queue, the subsequent processing step causes an TypeError:

TypeError: wrong argument type nil (expected Coolio::Loop)

The patch will add a check to ensure the watcher is still enabled before accessing the loop data. If the watcher is detached (enabled == 0), the pending event is ignored.

Types of Changes

  • Bug fix.

Contribution

This patch will fix a race condition where `Coolio_Loop_process_event` attempts to process an event for a watcher that has already been detached.

When detach is called (e.g., from another thread or a preceding callback in the same loop cycle),
the watcher's loop reference is cleared to nil.
If an event for this watcher was already pending in the libev queue,
the subsequent processing step causes an TypeError:

```
TypeError: wrong argument type nil (expected Coolio::Loop)
```

The patch will add a check to ensure the watcher is still enabled before accessing the loop data.
If the watcher is detached (enabled == 0), the pending event is ignored.
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.

TypeError: wrong argument type nil (expected Data) when processing a detached watcher

1 participant