Skip to content

fix: Dereferencing freed memos when verifying provisional memos #788

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

Merged

Conversation

MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Apr 9, 2025

Fixes #785

The root cause of #785 is that Salsa tries to load the memo of a cycle head that is stored on a tracked struct that has been freed.

The main problem is that we tried to verify validate_provisional even in cases where the query is from a past revision, in which case we can't trust any inputs to still exist (and be valid).

The fix in this PR is to change the order in which shallow_verify and validate_provisional are called. This requires extracting the mutating bits out of shallow_verify because we only want to call those if the struct isn't provisional (at least, that's what we did before and I tried to preserve this behavior).

Copy link

netlify bot commented Apr 9, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit d33d824
🔍 Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/67f6a077a9449d0008cbac8f

Copy link

codspeed-hq bot commented Apr 9, 2025

CodSpeed Performance Report

Merging #788 will not alter performance

Comparing MichaReiser:fix-dereference-freed-memos (d33d824) with master (c999c71)

Summary

✅ 12 untouched benchmarks

@MichaReiser MichaReiser force-pushed the fix-dereference-freed-memos branch 5 times, most recently from 5536c7c to 8b820db Compare April 9, 2025 15:57
@MichaReiser MichaReiser force-pushed the fix-dereference-freed-memos branch 2 times, most recently from 560b74f to 149f615 Compare April 9, 2025 16:04
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

@MichaReiser MichaReiser force-pushed the fix-dereference-freed-memos branch from 149f615 to 7e8c8e0 Compare April 9, 2025 16:26
@MichaReiser MichaReiser force-pushed the fix-dereference-freed-memos branch from 7e8c8e0 to d33d824 Compare April 9, 2025 16:29
@MichaReiser MichaReiser marked this pull request as ready for review April 9, 2025 16:31
@MichaReiser MichaReiser enabled auto-merge April 9, 2025 16:34
@MichaReiser MichaReiser added the bug Something isn't working label Apr 9, 2025
@MichaReiser MichaReiser added this pull request to the merge queue Apr 9, 2025
Merged via the queue into salsa-rs:master with commit 69272a8 Apr 9, 2025
11 checks passed
@MichaReiser MichaReiser deleted the fix-dereference-freed-memos branch April 9, 2025 16:50
@github-actions github-actions bot mentioned this pull request Apr 9, 2025
carljm pushed a commit to astral-sh/ruff that referenced this pull request Apr 9, 2025
## Summary

Update Salsa to pull in salsa-rs/salsa#788 which
fixes the, by now, famous *access to field whilst the value is being
initialized*.

This PR also re-enables all tests that previously triggered the panic.

## Test Plan

`cargo test`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tracked-structs: access to field whilst the value is being initialized
2 participants