Skip to content

A first attempt at an invariant#8

Merged
mjp41 merged 2 commits intophase3from
phase3inv1
Nov 25, 2024
Merged

A first attempt at an invariant#8
mjp41 merged 2 commits intophase3from
phase3inv1

Conversation

@mjp41
Copy link
Owner

@mjp41 mjp41 commented Nov 21, 2024

This creates a simple approach to checking an invariant on each step of the interpreter.

It exposes 3 Python builtins.

  • invariant_failure_src()
  • invariant_failure_tgt()
  • enableinvariant()

If there is an invariant failure, then it sets the src (source) and tgt (target) functions to be the values of the start and end of the edge that violates the region topology. Once a violation is detected the check is disabled.

The check can be reenabled by enableinvariant. We currently only enable the check on the first call to makeimmutable or once enableinvariant is called.

@mjp41
Copy link
Owner Author

mjp41 commented Nov 21, 2024

@xFrednet tagging you as I can't add you as a reviewer without you accepting the invitation

@xFrednet xFrednet self-requested a review November 22, 2024 11:15
Copy link
Collaborator

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

Nice start, some superficial NITs. The rest looks good to me :D

Copy link
Collaborator

@TobiasWrigstad TobiasWrigstad left a comment

Choose a reason for hiding this comment

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

Super! Only one thing really which I suspect is too early to do, but probably good to have discussed at some point.

/**
* Global status for performing the region check.
*/
bool do_region_check = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is probably over thinking this (or too early) but should these bits be part of the per-interpreter state? Or will the invariant check always stop all subinterpreters and then check? I am thinking we (eventually) need to support the existance of multiple threads while we are checking.

What I am thinking is that it may be wise to access these through an indirection already which allows us to lift these globals into something else later.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Not sure. This is very localised code, so lets design when we get there.

Copy link
Collaborator

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

LGTM

@mjp41 mjp41 merged commit 670349e into phase3 Nov 25, 2024
@mjp41 mjp41 deleted the phase3inv1 branch November 25, 2024 12:44
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.

3 participants