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

Stack overflow when cloning GooseUser with GooseUserData present #606

Open
jajce opened this issue Oct 15, 2024 · 0 comments
Open

Stack overflow when cloning GooseUser with GooseUserData present #606

jajce opened this issue Oct 15, 2024 · 0 comments

Comments

@jajce
Copy link

jajce commented Oct 15, 2024

Simple to reproduce. In any transaction set session data to a user and after that clone that user.

struct Session {
    jwt_token: String,
}

pub async fn reproduce_stack_bug(user: &mut GooseUser) -> TransactionResult {
    user.set_session_data(Session { jwt_token: "jwt_token".to_string() });
    let mut user_clone = user.clone();
    Ok(())
}

Code snippet with infinite recursion:

goose/src/goose.rs

Lines 822 to 843 in 1a8280e

pub trait GooseUserData: Downcast + Send + Sync + 'static {}
impl_downcast!(GooseUserData);
impl<T: Send + Sync + 'static> GooseUserData for T {}
trait CloneGooseUserData {
fn clone_goose_user_data(&self) -> Box<dyn GooseUserData>;
}
impl<T> CloneGooseUserData for T
where
T: GooseUserData + Clone + 'static,
{
fn clone_goose_user_data(&self) -> Box<dyn GooseUserData> {
Box::new(self.clone())
}
}
impl Clone for Box<dyn GooseUserData> {
fn clone(&self) -> Self {
self.clone_goose_user_data()
}
}

Error:

thread 'tokio-runtime-worker' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)
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

No branches or pull requests

1 participant