swiftlang/swift

[SR-927] Integrate leaks infrastructure into stdlib unittests

Open

#43.539 aperta il 12 mar 2016

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari)Swift (10.719 fork)batch import
good first issueimprovementstandard library

Metriche repository

Star
 (69.989 star)
Metriche merge PR
 (Merge medio 8g 17h) (510 PR mergiate in 30 g)

Descrizione

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.

Guida contributor