Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 5.5k
    • Issues 5.5k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 634
    • Merge requests 634
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #22327

Non-moving collector is unable to finalize weak pointers

Currently, the non-moving collector is unable to finalize weak pointers under some circumstances due to an interaction between the moving and non-moving collectors' weak pointer marking logic. Specifically, consider a case such as:

  nursery             ┆      non-moving gen.
                      ┆
                      ┆
                      ┆       K
                  ┌───┆────► ┌───────┐
                  │   ┆      │       │
                  │   ┆      │       │
                  │   ┆      │       │
   W              │   ┆      └───────┘
  ┌────────────┐  │   ┆
  │WEAK        │  │   ┆
  │ key        ├──┘   ┆
  │ value      ├──────┆──────► ...
  │ finalizer  │──────┆──────► ...
  └────────────┘      ┆
                      ┆
                      ┆
  1. At some point the weak will be promoted into the non-moving generation.
  2. At some point later, we will initiate a major collection and W will be moved to oldest_gen->old_weak_ptr_list (by initWeakForGC)
  3. We proceed with scavenging and eventually call traverseWeakPtrList, which will eventually call tidyWeakList(oldest_gen)
  4. We find that isAlive(w->key) == true as w->key is in the non-moving generation and isAlive necessarily conservatively considers any objects in the non-moving generation as alive
  5. We call scavengeLiveWeak on w, which will evacuate &w->key. As w->key is a non-moving object, it is pushed to the update-remembered set (see Note [Aging under the non-moving collector]).

At this point we are in a situation where w cannot be tombstoned by the nonmoving GC as w->key is reachable via the update-remembered set.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking