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-10333: Calendar.current.dateComponents([.weekday], from: Date()).weekday segfaults #2067
Conversation
@swift-ci test |
@swift-ci test |
Not sure if this is the correct fix or even complete but it seemed to make sense. |
Wow thanks Simon! As you say, looks like it makes sense, deferring to @millenomi for a proper review :) |
Hmm.. This was actually removed in 662f631, I wonder if that was a mistake or there was a good reason for it. |
@swift-ci test |
This isn't consistent with the semantics of Darwin's copy on write. If you get a COW calendar and you pass it to CF calls that alter the calendar, the backing calendar must not be altered if it hasn't been copied already. We should treat I also have an additional objection here: bridging should work with this object without need to alter |
i.e.: if I pass NSCOW to CF functions, |
What would be the correct way to retrieve Note the error is coming from the call:
where |
Here's what's happening:
So this needs to perhaps be figured out longer-term, but: your patch is correct if and only if you add a call like this:
so that any CF mutation function (e.g. |
…eekday segfaults - Override _NSCopyOnWriteCalendar._cfObject to return the backingCalendar created from CFCalendarCopyCurrent().
Ive added the copy, but just thinking when calling not-mutating |
@swift-ci test |
1 similar comment
@swift-ci test |
@spevans Yeah, that works. |
@swift-ci test and merge |
1 similar comment
@swift-ci test and merge |
from CFCalendarCopyCurrent().