#How to find tokio test deadlock

7 messages · Page 1 of 1 (latest)

dim yoke
#

I have an application with some tokio tests.
When I set the test to multi threaded it works fine, but if I use a single thread, the test deadlocks at the exact same position every time. Unfortunately I can't find the task which triggers this.

How do I figure out which code is at fault for this?

gilded saddle
#

what's the line of code that's deadlocking?

dim yoke
#

This function deadlocks.
The computation is finished successfully and sent to the channel. Just the other side of that channel never wakes up again.

I suspect the issue is in another task that runs during waiting for the computation and blocks.

I just can't find it.

pub async fn derive_key(&self, secret: Vec<u8>) -> Result<[u8; 32]> {
        let params = self.get_params().map_err(|err| anyhow!(err))?;
        let argon = Argon2::new(argon2::Algorithm::Argon2id, argon2::Version::V0x10, params);

        let salt_bytes = self.salt.as_bytes().to_owned();
        debug!("spawning blocking task");

        let result = tokio::task::spawn_blocking(move || {
            // debug!("running blocking task");
            let mut hash = [0u8; 32];
            let result = argon
                .hash_password_into(&secret, &salt_bytes, &mut hash)
                .map(move |_| hash)
                .map_err(|err| anyhow!(err));

            debug!("blocking computation ready");

            result
        })
        .await?;

        debug!("blocking task completed");

        result
    }
gilded saddle
#

why would that be related? ferrisThink

dim yoke
#

Ah, i thought I asked another question here. Oops.

#

Still no idea where the deadlock comes from. Gotta figure this out one day, but I have no idea on my own

gilded saddle
#

Could not reproduce it