Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Range retracing: Simulated code cannot safely access stored contexts after fork #90

Open
LinqLover opened this issue Jul 24, 2022 · 0 comments
Labels
bug Something isn't working engineering Technical change to the machinery

Comments

@LinqLover
Copy link
Collaborator

LinqLover commented Jul 24, 2022

The current mechanism for handling with copied contexts after a fork leaks because only simulator-side accesses to the contexts are forwarded to their copies. When the simulation code itself accesses any old contexts, such as via Context>>#methodReturnContext, the accesses are not forwarded. The exact scope of this issue is unclear, but below are some examples.

Possible solutions

  • Approach 1: Treat all context instances as symbolic and forward all read hooks to their copied instances, if any. Forward all write hooks, analogously.
    • This would be holistic, but likely will reduce performance.
    • Also, would it be nice if simulated code could explicitly access other forks via a metaprogramming interface (similar to accessing the data structure behind vectors)?
  • Approach 2: Create an explicit Context subclass that uses special code/primitives to access the relevant state. This would not be holistic.
  • Approach 3: As soon as any context instance is put on the stack, replace it. Would require some other hooks, though, might be more expensive and increase complexity.

Failing examples

c := Object newSubclass.
c compile: 'foo: x

	[^ x factorial]
		"value" "<- works"
		ensure: []'.
o := c new.
(TDBRetracingSimulator forMemory: TDBMemory new atTimes: (1 to: 3))
	evaluate:
		[o foo: thisContext tdbRetracingTimeIndex]

In other cases, a BlockCannotReturn is signaled from the simulated code when attempting a non-local return within an unwind context.

See #rangeRetracingForkAccess for more examples.

@LinqLover LinqLover added bug Something isn't working engineering Technical change to the machinery labels Jul 24, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working engineering Technical change to the machinery
Projects
None yet
Development

No branches or pull requests

1 participant