Skip to content

Propagate callback panics from Multi::perform, action and timeout - #695

Open
thelastbackspace wants to merge 1 commit into
sagebind:mainfrom
thelastbackspace:fix/694-multi-panic-propagate
Open

thelastbackspace wants to merge 1 commit into
sagebind:mainfrom
thelastbackspace:fix/694-multi-panic-propagate

Conversation

@thelastbackspace

Copy link
Copy Markdown

Fixes #694

When a callback panics during a Multi transfer, panic::catch stores the payload in the thread-local LAST_ERROR, but none of the Multi methods ever call panic::propagate(). So the transfer just fails with a write error, the panic stays in the slot, every callback on that thread gets skipped from then on, and the old panic finally comes out of the next unrelated Easy::perform.

This adds panic::propagate() after curl_multi_perform and curl_multi_socket_action (perform, action, timeout), the same way Easy::perform does it. It runs before the error is returned, so the panic is raised even when libcurl also reports an error.

I added panic_in_callback_is_propagated to tests/multi.rs. It panics in a header callback during a multi transfer, checks that the panic comes out of perform, then runs a plain Easy transfer on the same thread to make sure nothing was left behind. Without the fix the multi loop finishes quietly and the leftover panic shows up in the Easy::perform call.

A panic caught in a callback during a Multi transfer was stored in the
thread-local slot but never resumed, so it stayed there and blew up the
next unrelated Easy::perform on the same thread (and blocked all
callbacks until then). Call panic::propagate() after
curl_multi_perform and curl_multi_socket_action like Easy::perform does.

Fixes sagebind#694

This branch has not been deployed

No deployments
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.

Panic in a Multi transfer callback leaves stale panic state affecting subsequent transfers

1 participant