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-4470] [Blocker] Codegen difference between release and debug stdlib builds #47047

Open
dabrahams opened this issue Apr 2, 2017 · 5 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself optimized only Flag: An issue whose reproduction requires optimized compilation

Comments

@dabrahams
Copy link
Collaborator

Previous ID SR-4470
Radar rdar://problem/31394523
Original Reporter @dabrahams
Type Bug

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Miscompile, OptimizedOnly
Assignee @aschwaighofer
Priority Medium

md5: 7d897af7f1dd002a8500a04439b2e3ac

Issue Description:

I realize that this could be caused by using assertions with side-effects, but I don't believe I have any of those. I will manually chop out all assertion checks to verify (done, see below).

with

$ git fetch https://github.com/dabrahams/swift refs/bugs/refs/bugs/infinite-loop-2017-04-02:BUG && git checkout BUG

Build the stdlib and run the Prototypes/AU3.swift test (adding
--stdlib-unittest-in-process --stdlib-unittest-filter Substring to the test invocation) if you want to isolate the
issue. With a debug build of the standard library,

build-script --skip-build-ios-device --skip-build-tvos-device --skip-build-compiler-rt --debug-swift-stdlib --skip-build-benchmarks --release --swift-stdlib-assertions --swift-stdlib-build-type=Debug

invoking lit as follows

PATH="/Users/dave/src/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/bin:/Users/dave/src/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/llvm-macosx-x86_64/bin:/Users/dave/src/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/bin:/Users/dave/src/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/llvm-macosx-x86_64/bin:/Users/dave/bin:/Users/dave/brew/bin:/Users/dave/brew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
cd /Users/dave/src/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64
/Users/dave/src/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/llvm-macosx-x86_64/bin/llvm-lit -a Prototypes/AU3.swift.gyb --param swift_test_mode=optimize_none -v

which expands to this when the in-process/filter flags are added:

Miles:test-macosx-x86_64 dave$ rm -rf /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp && mkdir -p /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp && /Users/Shared/dabrahams/s/swift/utils/gyb -DWORD_BITS=64 /Users/Shared/dabrahams/s/swift/test/Prototypes/AU3.swift.gyb -o /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift
Miles:test-macosx-x86_64 dave$ /Users/Shared/dabrahams/s/swift/utils/line-directive /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift -- xcrun --toolchain default --sdk /Applications/Xcode-8E161.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./bin/swiftc -target x86_64-apple-macosx10.9  -module-cache-path '/var/folders/8v/9769m3ps7ds7h9pg23lzcls00000gn/T/swift-testsuite-clang-module-cacheMOVx2G' -F /Applications/Xcode-8E161.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/../../../Developer/Library/Frameworks -Xlinker -rpath -Xlinker /Applications/Xcode-8E161.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/../../../Developer/Library/Frameworks  -swift-version 3  /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift -o /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/a.out -Onone -g
/Users/Shared/dabrahams/s/swift/utils/line-directive /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift --  /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/a.out --stdlib-unittest-in-process --stdlib-
Miles:test-macosx-x86_64 dave$ /Users/Shared/dabrahams/s/swift/utils/line-directive /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift --  /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/a.out --stdlib-unittest-in-process --stdlib-unittest-filter Substring
StdlibUnittest: using filter: Substring
[ RUN      ] AnyUnicode.Substring
[       OK ] AnyUnicode.Substring
AnyUnicode: All tests passed

the test passes in 9 seconds.

With a release build of the standard library,

build-script --skip-build-ios-device --skip-build-tvos-device --skip-build-compiler-rt --release

invoking lit as follows

PATH="/Users/dave/src/s/build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin:/Users/dave/src/s/build/Ninja-ReleaseAssert/llvm-macosx-x86_64/bin:/Users/dave/src/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/bin:/Users/dave/src/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/llvm-macosx-x86_64/bin:/Users/dave/src/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/bin:/Users/dave/src/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/llvm-macosx-x86_64/bin:/Users/dave/bin:/Users/dave/brew/bin:/Users/dave/brew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
cd /Users/dave/src/s/build/Ninja-ReleaseAssert/swift-macosx-x86_64/test-macosx-x86_64
/Users/dave/src/s/build/Ninja-ReleaseAssert/llvm-macosx-x86_64/bin/llvm-lit -a Prototypes/AU3.swift.gyb --param swift_test_mode=optimize_none -v

which expands to

rm -rf /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp && mkdir -p /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp && /Users/Shared/dabrahams/s/swift/utils/gyb -DWORD_BITS=64 /Users/Shared/dabrahams/s/swift/test/Prototypes/AU3.swift.gyb -o /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift
/Users/Shared/dabrahams/s/swift/utils/line-directive /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift -- xcrun --toolchain default --sdk /Applications/Xcode-8E161.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/./bin/swiftc -target x86_64-apple-macosx10.9  -module-cache-path '/var/folders/8v/9769m3ps7ds7h9pg23lzcls00000gn/T/swift-testsuite-clang-module-cacheYfDPIw' -F /Applications/Xcode-8E161.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/../../../Developer/Library/Frameworks -Xlinker -rpath -Xlinker /Applications/Xcode-8E161.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/../../../Developer/Library/Frameworks  -swift-version 3  /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift -o /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/a.out -Onone -g
/Users/Shared/dabrahams/s/swift/utils/line-directive /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/out.swift --  /Users/Shared/dabrahams/s/build/Ninja-ReleaseAssert+stdlib-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64/Prototypes/Output/AU3.swift.gyb.tmp/a.out --stdlib-unittest-in-process --stdlib-unittest-filter Substring

it loops forever.

Other hashes

clang                              1a8a50564f Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
cmark                              d875488 Merge pull request #​4 from llvm-beanz/generate-cmark-exports
compiler-rt                        fef6bcb58 Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
llbuild                            c1b6082 Merge pull request #​132 from ddunbar/dir-tree-edges
lldb                               0854fdf1f Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
llvm                               da3e5888f42 Merge remote-tracking branch 'origin/swift-4.0-branch' into stable
Traceback (most recent call last):
@dabrahams
Copy link
Collaborator Author

@swift-ci create

@dabrahams
Copy link
Collaborator Author

Verified it's not assertion side-effects by testing with this change.

@aschwaighofer
Copy link
Member

The attached reduced test file also fails for me with an unoptimized DebugAssert stdlib:

$ xcrun -sdk macosx $PWD/buildbot_osx/swift-macosx-x86_64/bin/swiftc -Onone -g SR4470.swift
$ ./SR4470
<infinite loop>

@aschwaighofer
Copy link
Member

I don’t think this is IRGen - there seemed to have been many fixes to the unicode implementation since this bug was filed.

I am not going to spend more time on this since I doubt that this is a compiler issue.

@dabrahams
Copy link
Collaborator Author

Yes, I think we're no longer blocked by this. I'm sorry I didn't update the issue since then.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 optimized only Flag: An issue whose reproduction requires optimized compilation
Projects
None yet
Development

No branches or pull requests

2 participants