swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.57k stars 10.36k forks source link

[SR-10649] Existential specializer causes leaks #53049

Open eeckstein opened 5 years ago

eeckstein commented 5 years ago
Previous ID SR-10649
Radar rdar://problem/50595630
Original Reporter @eeckstein
Type Bug
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | @atrick | |Priority | Medium | md5: 30c18f8f73d5ed5581bb3f22a1b75165

Issue Description:

To reproduce:

  1. Build swift + the benchmarks with leak detection enabled:

utils/build-script --compiler-vendor=apple --skip-ios --skip-tvos --skip-watchos --skip-test-osx --swift-runtime-enable-leak-checker --build-subdir=buildbot_incremental_leaks_RA_R --release --assertions --swift-stdlib-enable-assertions=false

  1. in the swift build directory invoke the leak runner script:

build/buildbot_incremental_leaks_RA_R/swift-macosx-x86_64$ ./bin/Benchmark_RuntimeLeaksRunner

It reports some FAILs.

To run a single benchmark individually (select one of the fails), for example:

build/buildbot_incremental_leaks_RA_R/swift-macosx-x86_64$ ./bin/Benchmark_Onone --num-samples=2 435

It outputs a json with the number of leaked objects: swift_count and objc_count. The numbers must be 0 or equivalent in the last 2 runs. For example, this is a good output:

,TEST,SAMPLES,MIN(μs),MAX(μs),MEAN(μs),SD(μs),MEDIAN(μs)

{"name":"JSONPerfDecode", "swift_count": 0, "objc_count": 4, "swift_objects": [], "objc_objects": ["NSPlaceholderArray","NSPlaceholderDictionary","NSPlaceholderString","NSPlaceholderNumber"]} {"name":"JSONPerfDecode", "swift_count": 0, "objc_count": 4, "swift_objects": [], "objc_objects": ["NSPlaceholderArray","NSPlaceholderDictionary","NSPlaceholderString","NSPlaceholderNumber"]} {"name":"JSONPerfDecode", "swift_count": 0, "objc_count": 4, "swift_objects": [], "objc_objects": ["NSPlaceholderArray","NSPlaceholderDictionary","NSPlaceholderString","NSPlaceholderNumber"]} 435,JSONPerfDecode,2,302,306,304,3,302

A bad output lists all the leaked objects (can be very long).

This leak was triggered by enabling the existential specializer: https://github.com/apple/swift/pull/19820

eeckstein commented 5 years ago

Reverting in https://github.com/apple/swift/pull/24646

atrick commented 5 years ago

PR https://github.com/apple/swift/pull/25038