Skip to content

fix ELF/DWARF leak #79155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/public/RuntimeModule/Dwarf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ protocol DwarfSource {

}

struct DwarfReader<S: DwarfSource> {
struct DwarfReader<S: DwarfSource & AnyObject> {

typealias Source = S
typealias Address = UInt64
Expand All @@ -513,7 +513,7 @@ struct DwarfReader<S: DwarfSource> {
var end: Address { return base + size }
}

var source: Source
unowned var source: Source

struct AbbrevInfo {
var tag: Dwarf_Tag
Expand Down
5 changes: 3 additions & 2 deletions stdlib/public/RuntimeModule/Elf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1793,8 +1793,9 @@ final class ElfImage<SomeElfTraits: ElfTraits>
}
}

private lazy var dwarfReader
= try? DwarfReader(source: self, shouldSwap: header.shouldByteSwap)
private lazy var dwarfReader = { [unowned self] in
try? DwarfReader(source: self, shouldSwap: header.shouldByteSwap)
}()

typealias CallSiteInfo = DwarfReader<ElfImage>.CallSiteInfo

Expand Down