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-320] reference counting problem with NSCalendar.currentCalendar() #4370

Closed
swift-ci opened this issue Dec 19, 2015 · 6 comments
Closed

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-320
Radar None
Original Reporter papierschiff (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

swift2.2 (10.12.15), ubuntu 14.04

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, CoreFoundation, Linux
Assignee None
Priority Medium

md5: 65e4db0691d09d7231be031ea0f38322

Issue Description:

when i use NSCalendar.currentCalendar() after a short time (in my example after the 4. call) the program crashs with the output:

/home/buildslave/jenkins/workspace/oss-swift-linux-packages-ubuntu_14_04/swift/include/swift/Runtime/../../../stdlib/public/SwiftShims/RefCount.h:207: bool StrongRefCount::doDecrementShouldDeallocate() [ClearPinnedFlag = false]: Assertion `newval + quantum >= RC_ONE && "releasing reference with a refcount of zero"' failed.
Aborted (core dumped)
@gottesmm
Copy link
Member

Is this with optimization?

@swift-ci
Copy link
Contributor Author

Comment by markus sähn (JIRA)

no optimization.

@phausler
Copy link
Member

Since NSCalendar is a bridged CF type it may be a failure in the ref counting from the bridge itself.

@phausler
Copy link
Member

I added a unit test (currently disabled); this only exhibits on linux builds -
Process 41490 stopped

  • thread Fixing whitespace formatting #1: tid = 41490, 0x00007ffff7b0ad0f libswiftCore.so, name = 'TestFoundation', stop reason = signal SIGTRAP
    frame #0: 0x00007ffff7b0ad0f libswiftCore.so
    -> 0x7ffff7b0ad0f: nop
    (lldb) bt

  • thread Fixing whitespace formatting #1: tid = 41490, 0x00007ffff7b0ad0f libswiftCore.so, name = 'TestFoundation', stop reason = signal SIGTRAP

  • frame #0: 0x00007ffff7b0ad0f libswiftCore.so
    frame Fixing whitespace formatting #1: 0x00007ffff731fae5 libFoundation.so`NSCalendar.AMSymbol.getter(self=0x000000000083cce0) + 213 at NSCalendar.swift:280
    frame Fixing grammar issue #2: 0x000000000041904b TestFoundation`TestNSCalendar.test_currentCalendarRRstability(self=0x00000000007e31a0) -> () + 155 at TestNSCalendar.swift:85
    frame Syntax highlighting in README.md #3: 0x000000000041969a TestFoundation`partial apply + 26 at TestNSCalendar.swift:0
    frame Add @noescape to Synchronous Enumeration, Predicate, and Comparator Blocks #4: 0x0000000000412711 TestFoundation`thunk + 17 at TestNSRunLoop.swift:0
    frame Verify contents of the file attributes dictionary #5: 0x00000000004163c1 TestFoundation`partial apply for thunk + 81 at TestNSCalendar.swift:0
    frame Fix URL in README.md #6: 0x00007ffff6d382ee libXCTest.so`ext.XCTest.XCTest.XCTestCase.invokeTest () -> () + 6014
    frame Use Correct Source Index in NSArray.getObjects #7: 0x00007ffff6d35ee8 libXCTest.so`XCTest.XCTMain (Swift.Array<XCTest.XCTestCase>) -> () + 328
    frame [WIP] Implement NSRangeFromString #8: 0x0000000000412229 TestFoundation`main + 1897 at main.swift:61
    frame Use Array.reserveCapacity in NSArray/NSMutableArray #9: 0x00007ffff5b47ec5 libc.so.6`__libc_start_main(main=(TestFoundation`main at main.swift), argc=1, argv=0x00007fffffffe478, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffe468) + 245 at libc-start.c:287
    frame Fix download link #10: 0x00000000004119f9 TestFoundation
    (lldb) up
    frame Fixing whitespace formatting #1: 0x00007ffff731fae5 libFoundation.so`NSCalendar.AMSymbol.getter(self=0x000000000083cce0) + 213 at NSCalendar.swift:280
    277 }
    278
    279 public var AMSymbol: String {
    -> 280 return _symbol(kCFDateFormatterAMSymbolKey)
    281 }
    282
    283 public var PMSymbol: String {
    (lldb) p self
    (Foundation.NSCalendar) $R0 = 0x000000000083cce0 {
    Foundation.NSObject = {}
    _base = (info = 8832, pad = 0)
    identifier = 0x00007ffff77da138 libFoundation.so`_kCFCalendarIdentifierGregorian
    _locale = 0x0000000000000000
    _localeID = 0x00007ffff77d2398 libFoundation.so`_CFLocaleCopyCurrentGuts.str
    _tz = 0x00000000007f1040 -> 0x00007ffff77cd238 full type metadata for Foundation.NSTimeZone + 16
    _cal = 0x0000000000000000
    }
    (lldb) po self
    <NSCalendar: 0x83cce0>

@swift-ci
Copy link
Contributor Author

Comment by Collin Hundley (JIRA)

This is an old issue, but I'm experiencing the exact same problem on Swift 3 snapshot 08-23. Was this issue ever resolved?

@spevans
Copy link
Collaborator

spevans commented Aug 24, 2018

The calendar releasing issue was fixed in SR-2879.

The unit test that Philippe added uncovered a different bug that was resolved in #1472

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
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

4 participants