swiftlang / swiftlang/swift-corelibs-libdispatch

[SR-10813] DispatchWorkItem leak on armv7

Open
#616 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Leak libdispatch
Dominant language
C
Stars
2.6k
Forks
496
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Previous ID SR-10813
Radar None
Original Reporter Pogonets (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s libdispatch
Labels Bug, Leak
Assignee None
Priority Medium

md5: 5987bd4bd4977311481d967a3a2e3298

Issue Description:

We found memory leak with DispatchWorkItem on android-armv7
After a quick research, this leak doesn't reproduce on linux x86_64 and android arm64
So looks like it affects all 32bit platforms
Here is a sample:

import Dispatch

let group = DispatchGroup()
let queue = DispatchQueue.global()

class A {
    deinit {
        print("deinit")
    }
}

func test() {
    let a = A()
    queue.async(group: group, execute: DispatchWorkItem {
        print(a)
    })
}

test()
group.wait()

deinit not called
And without DispatchWorkItem this code also works fine

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided DispatchWorkItem sample on android-armv7 and compare its behavior with linux x86_64 and android arm64, where the leak does not reproduce. Trace the libdispatch component involved in DispatchWorkItem and verify the fix by confirming that A's deinit is called after group.wait().

Written by the indexing model from the issue text.

Assessment

Tech stack
c, swift
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.