Skip to content

Use a version number for idempotency.#107

Merged
vext01 merged 1 commit intoykjit:mainfrom
ltratt:fix_idempotent
Mar 19, 2025
Merged

Use a version number for idempotency.#107
vext01 merged 1 commit intoykjit:mainfrom
ltratt:fix_idempotent

Conversation

@ltratt
Copy link
Contributor

@ltratt ltratt commented Mar 14, 2025

It can happen -- we've seen it! -- that two Protos, allocated at different times, end up at the same address P. load_inst then implicitly treats them as the same Proto even though they might be completely different.

In this commit, we attach a "proto version" to every Proto, which records what the global_proto_version was when the Proto was constructed. Every time a Proto is freed, we increment this version. Thus two Protos at the same address will always have different "proto versions", invalidating any traces specialised to the old Proto, while not invaldating traces for other Protos that are still alive.

src/lvm.c Outdated
// because idempotent support isn't yet implemented for 32-bit return values.
__attribute__((yk_idempotent))
uint64_t yk_load_inst(const Instruction *pc) {
uint64_t load_inst(__attribute__((unused)) uint64_t pv, const Instruction *pc) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Better remove unused because it now is, and that might confuse us and/or the compiler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3af3722.

@vext01
Copy link
Contributor

vext01 commented Mar 14, 2025

please squash.

It can happen -- we've seen it! -- that two `Proto`s, allocated at
different times, end up at the same address P. `load_inst` then
implicitly treats them as the same `Proto` even though they might be
completely different.

In this commit, we attach a "proto version" to every `Proto`, which
records what the `global_proto_version` was when the `Proto` was
constructed. Every time a `Proto` is freed, we increment this version.
Thus two `Proto`s at the same address will always have different "proto
versions", invalidating any traces specialised to the old `Proto`, while
not invaldating traces for other `Proto`s that are still alive.
@ltratt
Copy link
Contributor Author

ltratt commented Mar 15, 2025

I'm now fairly confident that we really have fixed a bug here (I am investigating an entirely separate issue in yk that I thought was correlated, but I'm now fairly confident isn't). I think we can merge this, and update the yklua commit in yk.

@vext01 vext01 added this pull request to the merge queue Mar 15, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 15, 2025
@ltratt
Copy link
Contributor Author

ltratt commented Mar 17, 2025

@vext01 I think we should retry this one.

@vext01 vext01 added this pull request to the merge queue Mar 17, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 17, 2025
@vext01 vext01 added this pull request to the merge queue Mar 19, 2025
Merged via the queue into ykjit:main with commit c2acf45 Mar 19, 2025
2 checks passed
@ltratt ltratt deleted the fix_idempotent branch April 17, 2025 07:10
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.

2 participants