swiftlang/swift

[SR-927] Integrate leaks infrastructure into stdlib unittests

Open

#43,539 创建于 2016年3月12日

在 GitHub 查看
 (4 评论) (0 反应) (0 负责人)Swift (69,989 star) (10,719 fork)batch import
good first issueimprovementstandard library

描述

Previous ID SR-927
Radar None
Original Reporter @gottesmm
Type Improvement
Votes 0
Component/s Standard Library
Labels Improvement, StarterBug
Assignee None
Priority Medium

md5: af9683a46d2c1fd2060e2a6887b581f4

Issue Description:

Currently we have special infrastructure for precise leaks checking that we use to check for leaks in our benchmarks.

The way this works is that when the pass -DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER is set to yes, the runtime provides the two entry points:

swift_leaks_startTrackingObjects(const char *name)
swift_leaks_stopTrackingObjects(const char *name)

where name is a string with the name of the test being run. When startTrackingObjects is called, a global set is initialized. This is our "live object set". From that point forward, whenever we allocate a swift or objective-c object, we add it to the set. When ever we deallocate such an object, we remove the object from that set.

When stopTrackingObjects is called, the runtime emits via simple json the current state of the live object set.

The nice thing about this approach is that it enables fine-grained leaks testing of specific tests.

As mentioned at the top of the description, currently the leak checker has been integrated only into the benchmarks. This bug is to track the work of making changes to stdlib unit tests to enable the leaks checker to work on the stdlib unit tests.

This is a non-trivial amount of work, but would be a good starter bug that would improve the quality of the compiler.

贡献者指南

[SR-927] Integrate leaks infrastructure into stdlib unittests · swiftlang/swift#43539 | Good First Issue