squeak-smalltalk / squeak-object-memory

Issues and assets related to the Squeak object memory.
https://bugs.squeak.org
MIT License
11 stars 1 forks source link

PointerFinder is not proxy-safe #47

Open LinqLover opened 2 years ago

LinqLover commented 2 years ago

PointerFinder>>#follow:from: sends shouldFollowOutboundPointers to all instances in the system, but some instances might be proxies that refuse to implement shouldFollowOutboundPointers correctly. If the proxy does not work correctly, as is often the case during development, this will break the pointer finder.

Maybe Object>>#shouldFollowOutboundPointers should be moved into a method on PointerFinder to avoid method lookup. See also: https://github.com/hpi-swa/Squot/blob/4159c4831b5fef0b02c8e3b43559792f53746391/src/Squot.package/SquotDecorator.class/instance/shouldFollowOutboundPointers.st

LinqLover commented 6 months ago

Hi all, hi @eliotmiranda,

I'm still experiencing this issue and issue and would like to solve it. The problem is that the pointer finder sends outboundPointersDo: and shouldFollowOutboundPointers to all (reachable) objects in the system, including instances of ProtoObject. Some proxy classes that do not inherit from Object might respond with side effects to these messages (e.g., an ObjectTracer will bring up a debugger, an MCInfoProxy will perform an expensive materialization[^1], a void ProtoObject basicNew will raise an MNU).

I see three possible options to fix this:

  1. All proxies have to implement these messages by itself. Pro: proxies remain in control over pointer finding, ProtoObject looks clean. Con: extra effort for every (!) inheritor of ProtoObject, legacy code still breaks the pointer finder.
  2. Do not dispatch pointer finding to objects but use mirror style enumeration. Pro: issue is fixed globally. Con: proxies no longer can customize pointer finding.
  3. Move up pointer finding methods from Object to ProtoObject. Pro: most legacy will not need to be changed, proxies may still choose to customize pointer finding. Con: ProtoObject interface becomes slightly messier.

In the end, the question seems to be about whether pointer finding is a capability that proxies regularly should or want to customize, or whether it should perfectly imitate the object graph/GC as seen/performed by the VM. I tend to the latter perspective, but could also imagine that one might want to use the pointer finder to chase the pointers in a network of connected images (e.g., Croquet). While technically not the cleanest, option 3 would switch the default assumption from 1 to 2 while still leaving proxies the option to opt in.

Looking forward to your opinion!

Best, Christoph

PS: See also this discussion[^2].

[^1]: [squeak-dev] Re: [squeak-dev] Serious garbage/storage leak issue with MCInfoProxy [^2]: [squeak-dev] Re: [squeak-dev] what is a transparent proxy?