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-15302] AttributedString mis-compilation on Linux x86_64 with rebranch #57624

Closed
compnerd opened this issue Oct 11, 2021 · 7 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@compnerd
Copy link
Collaborator

Previous ID SR-15302
Radar None
Original Reporter @compnerd
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @compnerd
Priority Medium

md5: c31f76109ebd2918e05a0e3882c68286

Issue Description:

There seems to be a mis-compilation on Linux x86_64 with CFAttributedString that the rebranch uncovered. @etcwilde and I managed to reduce it down to a single file, but have not reduced it further. Unfortunately, it involves LICM, LoadStoreHoisting, and inlining potentially. In order to unblock the rebranch, this file might need to be optimized at -O0 on linux.

The following are the known failing tests associated with this issue:

The following tests FAILED:
        1602 - TestFoundation.TestNSAttributedString-test_enumerateAttributes (Failed)
        1623 - TestFoundation.TestNSMutableAttributedString-test_reverse_attribute_enumeration_with_extend_attributed_replace (Failed)
        1624 - TestFoundation.TestNSMutableAttributedString-test_direct_attributes_enumeration_with_extend_attributed_replace (Failed)
        1625 - TestFoundation.TestNSMutableAttributedString-test_reverse_attributes_enumeration_with_extend_attributed_replace (Failed)
        1628 - TestFoundation.TestNSMutableAttributedString-test_direct_attributes_enumeration_with_reduct_attributed_replace (Failed)
        1629 - TestFoundation.TestNSMutableAttributedString-test_reverse_attributes_enumeration_with_reduct_attributed_replace (Failed)
        1630 - TestFoundation.TestNSMutableAttributedString-test_direct_attribute_enumeration_with_extend_replace (Failed)
        1631 - TestFoundation.TestNSMutableAttributedString-test_reverse_attribute_enumeration_with_extend_replace (Failed)
        1632 - TestFoundation.TestNSMutableAttributedString-test_direct_attributes_enumeration_with_extend_replace (Failed)
        1633 - TestFoundation.TestNSMutableAttributedString-test_reverse_attributes_enumeration_with_extend_replace (Failed)
        1634 - TestFoundation.TestNSMutableAttributedString-test_direct_attribute_enumeration_with_reduct_replace (Failed)
        1635 - TestFoundation.TestNSMutableAttributedString-test_reverse_attribute_enumeration_with_reduct_replace (Failed)
        1636 - TestFoundation.TestNSMutableAttributedString-test_direct_attributes_enumeration_with_reduct_replace (Failed)
        1637 - TestFoundation.TestNSMutableAttributedString-test_reverse_attributes_enumeration_with_reduct_replace (Failed)
        1845 - TestFoundation.TestAttributedString-testConversionFromObjC (ILLEGAL)
        1848 - TestFoundation.TestAttributedString-testIncompleteConversionFromObjC (ILLEGAL)
        1850 - TestFoundation.TestAttributedString-testConversionNestedScope (ILLEGAL)
        1855 - TestFoundation.TestAttributedString-testConversionCoalescing (ILLEGAL)

Unfortunately, it is very difficult to debug. lldb consistently crashes when trying to execute any of these tests and gdb is unable to show a valid stack trace. Additionally, these only happen on optimized builds, so that throws more fun into the mix.

@compnerd
Copy link
Collaborator Author

@etcwilde was able to validate an approach that I had in mind. The issue is in the C/C++ side and we can test with the upstream clang. Using that, we were able to validate that CF built with upstream clang does fix the issue, which means that this has been fixed upstream. We can bisect to find the fix.

@etcwilde
Copy link
Member

I'm able to successfully build and run the Foundation tests on top of the upstream TOT clang.

The failing llvm-project commit on https://github.com/apple/llvm-project: 09506be
The successful llvm-project commit on https://github.com/llvm/llvm-project: 7f55209cee55fa2f7d5954f7ec7df77d90585a7b

I'll script something up to bisect it tomorrow morning and get it cherry-picked as necessary.

@etcwilde
Copy link
Member

$ git merge-base 09506be7b24183ab1073f61d78456dfe99d51608 7f55209cee55fa2f7d5954f7ec7df77d90585a7b
d2972116923a124de71cea006eca3068bdc381ea

@etcwilde
Copy link
Member

Alright, I think I've narrowed the fix down to llvm commit 909cba969981032c5740774ca84a34b7f76b909b. Time to cherry-pick and see if things keep exploding.

@etcwilde
Copy link
Member

I've posted the cherry-pick of the fix here apple/llvm-project#3439 and re-enabled optimizations in corelibs-foundation here apple/swift-corelibs-foundation#3091

@etcwilde
Copy link
Member

Alright, cherry-pick has been merged.

@etcwilde
Copy link
Member

The cherry-pick PR that fixes this has been merged and optimizations have been re-enabled for CFAttributedString.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants