Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,968
    • Issues 4,968
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 474
    • Merge requests 474
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • 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 Compiler
  • GHCGHC
  • Issues
  • #15417
Closed
Open
Created Jul 19, 2018 by Ömer Sinan Ağacan@osa1Maintainer

Weak pointers to static objects are sometimes not detected as unreachable

(See also the mailing list thread)

Static objects with no SRTs and pointer fields are currently ignored by evacuate(). This is efficient but causes trouble when checking alive-ness of static objects in isAlive(), which is used for (among other things) checking whether a weak's key has died. This causes leaks as value of a weak with static key will always be kept alive.

Here's a demonstration:

module Main where

import System.Mem.Weak (mkWeak, deRefWeak)
import System.Mem (performMajorGC)

mkKey :: IO String
mkKey = readFile "/dev/random"

-- mkKey :: IO Int
-- mkKey = return 1

main :: IO ()
main = do
    w <- mkKey >>= \k -> mkWeak k () Nothing
    performMajorGC
    performMajorGC
    performMajorGC
    deRefWeak w >>= print

The idea is that the first mkKey function returns a non-static string and this program prints Nothing. If I enable the second mkKey function the key is now a static object and the program prints Just ().

Trac metadata
Trac field Value
Version 8.5
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Runtime System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited Mar 10, 2019 by Simon Marlow
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking