<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">This isn’t it, because we always call through to swift_release in CFRelease on Linux, because the CFString is a swift type under the hood.<div class=""><br class=""></div><div class="">We may be able to change this to check for a CF specific hack of some kind, but in the meantime adding the retain works.</div><div class=""><br class=""></div><div class="">PR here:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift-corelibs-foundation/pull/1351" class="">https://github.com/apple/swift-corelibs-foundation/pull/1351</a></div><div class=""><br class=""></div><div class="">- Tony<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 29, 2017, at 8:31 PM, Philippe Hausler &lt;<a href="mailto:phausler@apple.com" class="">phausler@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class="">I think that perhaps we have a problem with the retain count flags in the definition of CFSTR. Previously the pinned reference would prevent the deallocation. This may have gotten clobbered with the latest CF import.<br class=""><br class=""><div class="">Sent from my iPhone</div><div class=""><br class="">On Nov 29, 2017, at 7:55 PM, Brandon Williams via swift-corelibs-dev &lt;<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">Hey Tony,</div><div class=""><br class=""></div><div class="">We were able to fix our crashes by avoiding our uses of `URLQueryItem`s. In one place I had to completely remove the use of `URLQueryItem`:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/pointfreeco/swift-web/pull/79/files#diff-293b73a926ba418bd9511ef735fc947cL147" target="_blank" class="">https://github.com/pointfreeco/swift-web/pull/79/files#diff-293b73a926ba418bd9511ef735fc947cL147</a><br class=""></div><div class=""><br class=""></div><div class="">And in another my colleague Stephen Celis discovered that duplicate keys in a query string can cause this to crash:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/pointfreeco/swift-web/pull/80" class="">https://github.com/pointfreeco/swift-web/pull/80</a><br class=""></div><div class=""><br class=""></div><div class="">He was able to come up with a minimal test case to demonstrate this:</div><div class=""><br class=""></div><a href="https://github.com/pointfreeco/swift-web/commit/cfa9b519a829f1c1627620521326f0877c2d023a" class="">https://github.com/pointfreeco/swift-web/commit/cfa9b519a829f1c1627620521326f0877c2d023a</a><div class=""><br class=""></div><div class="">And you can see the failure in this Travis CI report:</div><div class=""><br class=""></div><div class=""><a href="https://travis-ci.org/pointfreeco/swift-web/builds/309316418?utm_source=email&amp;utm_medium=notification" class="">https://travis-ci.org/pointfreeco/swift-web/builds/309316418</a></div><div class=""><br class=""></div><div class="">At the bottom you’ll find:</div><div class=""><br class=""></div><div class=""><div class="">```fatal error: Constant strings cannot be deallocated: file Foundation/NSCFString.swift, line 118```</div><div class=""><br class=""></div><div class="">So definitely seems to be in that area!</div><div class=""><br class=""></div><div class="">Now, as far as rebuilding swift-corelibs-foundation, I’m down to try but I dont really know much about how to do that. With some instructions I could give it a shot.</div><div class=""><br class=""></div><div class="">Thanks for the help!</div><div class=""><br class=""></div><div class=""><br class=""></div></div><div class=""><br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Nov 29, 2017 at 5:59 PM Tony Parker &lt;<a href="mailto:anthony.parker@apple.com" target="_blank" class="">anthony.parker@apple.com</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class="">I see a couple of places that are suspicious there:<div class=""><br class=""></div><div class="">Description:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L66" target="_blank" class="">https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L66</a></div><div class=""><br class=""></div><div class="">And the nameString / valueString constants in the copy query items function:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L1057" target="_blank" class="">https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L1057</a></div><div class=""><a href="https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L1079" target="_blank" class="">https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L1079</a></div><div class=""><a href="https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L1104" target="_blank" class="">https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L1104</a></div><div class=""><a href="https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L1134" target="_blank" class="">https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L1134</a></div><div class=""><a href="https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L1158" target="_blank" class="">https://github.com/apple/swift-corelibs-foundation/blob/master/CoreFoundation/URL.subproj/CFURLComponents.c#L1158</a></div><div class=""><br class=""></div><div class="">Do you have the ability to re-build swift-corelibs-foundation and run a test? I suspect if you replace those with CFRetain(CFSTR(…)) then it will fix your crash.</div><div class=""><br class=""></div><div class=""></div></div><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class="">- Tony</div></div><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Nov 29, 2017, at 2:06 PM, Brandon Williams &lt;<a href="mailto:mbw234@gmail.com" target="_blank" class="">mbw234@gmail.com</a>&gt; wrote:</div><br class="m_-2036326282292254873m_435483929937444131Apple-interchange-newline"><div class=""><div dir="ltr" class="">Thanks for the info!<div class=""><br class=""></div><div class="">FWIW, most of the places I have encountered this so far have made use of `URLComponents`, and have even been able to eliminate the crash by getting rid of that code in a few places. The other JIRA bug on this topic also mentions URLComponents in their repro case. Seems to be the culprit.</div><div class=""><br class=""></div><div class="">Also worth noting that in the above cases dealing with URLComponents the crash only happens in DEBUG compilations, not RELEASE.</div><div class=""><br class=""></div><div class="">However, I do have another one of these crashes that _does_ happen on RELEASE builds that I haven’t yet been able to reduce.</div><div class=""><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Nov 29, 2017 at 4:43 PM Tony Parker &lt;<a href="mailto:anthony.parker@apple.com" target="_blank" class="">anthony.parker@apple.com</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class="">Hi Brandon,<div class=""><br class=""></div><div class="">This is probably a bug in the CoreFoundation C sources part of swift-corelibs-foundation. Unlike Darwin platforms, we can’t make the CFSTR(“”) macro produce a CFStringRef that cannot be overreleased. Probably there is a constant string returned from CF function, then the Swift runtime assumes it can release it, and bam we wind up with an overrelease.</div><div class=""><br class=""></div><div class="">We’ll have to track down which function is getting called, which probably just requires stepping through that test case with a debugger…</div><div class=""><br class=""></div><div class=""></div></div><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class="">- Tony<br class=""></div></div><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 29, 2017, at 1:34 PM, Brandon Williams via swift-corelibs-dev &lt;<a href="mailto:swift-corelibs-dev@swift.org" target="_blank" class="">swift-corelibs-dev@swift.org</a>&gt; wrote:</div><br class="m_-2036326282292254873m_435483929937444131m_-9212223342634817513Apple-interchange-newline"></blockquote></div></div></div><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class=""><div class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">Hello all!</div><div class=""><br class=""></div><div class="">We’ve been encountering this runtime error quite a bit recently, and we have no idea why. We’ve filed a bug and there’s one other on JIRA related to this, but both without any comments:</div><div class=""><br class=""></div><a href="https://bugs.swift.org/browse/SR-6422" target="_blank" class="">https://bugs.swift.org/browse/SR-6422</a><br class=""><div class=""><a href="https://bugs.swift.org/browse/SR-6398" target="_blank" class="">https://bugs.swift.org/browse/SR-6398</a><br class=""></div><div class=""><br class=""></div><div class="">We’re curious if others are aware of this and or has more info? Is it a red herring for some other problem?</div><div class=""><br class=""></div><div class="">Any info would be helpful!</div></div></div></blockquote></div></div></div><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">
_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" target="_blank" class="">swift-corelibs-dev@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</a><br class=""></div></blockquote></div></div></div></blockquote></div>
</div></blockquote></div><br class=""></div></div></blockquote></div></div></div>
</div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-corelibs-dev mailing list</span><br class=""><span class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev" class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</a></span><br class=""></div></blockquote></div></div></blockquote></div><br class=""></div></body></html>