Skip to content

conservative stack scanning? #11714

@StefanKarpinski

Description

@StefanKarpinski

Instead of maintaining our own GC stack frames – which is slow and easy to mess up, likely accounting for a large portion of our tough-to-track-down core Julia bugs in the past years – we've occasionally talked about doing conservative stack scanning. That is, scanning the stack and conservatively assuming that anything that happens to look like a pointer to a valid heap-allocated Julia object actually is.

Pros:
Cons:
  • might retain objects that should be freed
  • pointers passed into C code could still expect objects to live but not point to the head of the object
  • performance of stack scanning

The second con seems like it can be avoided with the same kind of rooting we do now, except only needed at the ccall entry point. The chances of the first con happening – i.e. random values in the stack pointing valid heap objects – seems pretty slim. There might be situations like when you take a pointer to an array and then use it – but in that case you probably want the array to remain rooted while someone has a pointer to it. Are there other potential cons that I'm not seeing?

Related: #10725, #10317.

cc: @carnaval, @vtjnash, @JeffBezanson

Metadata

Metadata

Assignees

No one assigned

    Labels

    GCGarbage collectorneeds decisionA decision on this change is neededperformanceMust go fasterspeculativeWhether the change will be implemented is speculative

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions