Skip to content
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

[SR-6391] Repeated invocation of ProcessInfo.hostname causes unbounded heap growth #4057

Open
swift-ci opened this issue Nov 15, 2017 · 1 comment

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-6391
Radar None
Original Reporter swizzlr (JIRA User)
Type Bug
Status In Progress
Resolution
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee swizzlr (JIRA)
Priority Medium

md5: eb2a2f92784172873e4d6e8c88472cf1

Issue Description:

This was a fun bug to track down. `massif` is amazing, tho.

https://github.com/apple/swift-corelibs-foundation/blob/swift-4.0-branch/Foundation/Host.swift#L85 is the line where _addresses is appended to with a string.

_resolveCurrent() is called by _resolve() when `_resolved` is set to false. The bug is here: `_resolved` is, as far as I can tell, never set to `true`.

_resolve() is called in the `names` getter; the `names` getter is called by `name`'s getter, which is called by ProcessInfo.hostname against the `Host.current()` object.

Fix is to set _resolved to `true` after `_resolveCurrent()` succeeds.

Workaround is to cache the hostname elsewhere.

@swift-ci
Copy link
Contributor Author

Comment by Thomas Catterall (JIRA)

#1320

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from swiftlang/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant