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

Recursive function calls using multi-threading triggers assertion #129

Open
stlemme opened this issue Aug 23, 2022 · 0 comments
Open

Recursive function calls using multi-threading triggers assertion #129

stlemme opened this issue Aug 23, 2022 · 0 comments

Comments

@stlemme
Copy link
Member

stlemme commented Aug 23, 2022

//minified repro sample
fn rec_func_wrapper(n: i32) -> i32 {
	// an @ for rec_func() does not trigger the assertion, but causes full unrolling of the recursion
	fn rec_func(x: i32) -> i32 {
		if x == 0 {
			1
		} else {
			let buffer = alloc_cpu(sizeof[i32]());
			let data = buffer.data as &mut [i32];

			// removing the threading logic and computing rec_func(x-1) directly does not show the issue
			let task = spawn(|| {
				data(0) = rec_func(x-1);
			});

			let tid = task();

			sync(tid);

			let result = data(0);
			release(buffer);

			if result > 0 { 1 } else { 0 }
		}
	}

	rec_func(n)
}


#[export]
fn main() -> i32 {
	let t = rec_func_wrapper(5);

	if t > 0 { 0 } else { -1 }
}

triggers Assertion failed: odef->op(i) != odef, file D:\Projects\anydsl\thorin\src\thorin\transform\importer.cpp, line 80

and in previous versions of thorin this ended up with a stack overflow.

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