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-8248] Optimization mode causes weird bug #50780
Comments
Sorry, what stops working in optimized mode? I still see the app being launched and the information about the test file printed. |
Comment by Lincoln Law (JIRA) Except none optimization mode, it'll play the music, you can hear. |
Ah, I didn't realize the only difference was the sound, and I didn't realize you'd set the default mode to -Onone in both Debug and Release in the APlay framework target. I can reproduce the difference now. @swift-ci create |
I investigated this a bit and found that there is no optimizer problem here. The only difference between a good and bad version is a minor difference in stack layout which should not have any impact. I also did run the attached sample program with the address sanitizer. It reports a heap buffer overflow when dealing with C-strings (in StreamProvider.URLInfo.localFileHit). |
Comment by Lincoln Law (JIRA) TestDemo-Fixed-localfileHint.zip Hi Erik, I fixed (StreamProvider.URLInfo.localFileHit) with address sanitizer in -OSize, but still got error |
The new ASAN crash is still a bug in your code. You are taking an unsafe pointer from a swift UInt8 array without keeping the array alive. |
Comment by Lincoln Law (JIRA) Hi Erik, that is the point why I file the radar. No crash at -Onone but -OSize |
The problem here is that by not keeping the array alive, you are running into undefined behavior. That means it can work in one optimization level but not in another optimization level. |
Comment by Lincoln Law (JIRA) Ok, thanks Erik, I'll check my code later. Thanks for all. |
Comment by Lincoln Law (JIRA) Hi Erik, fixed array life time issue, but still got cpu 100% using in -OSize mode, not in -Onone mode |
Comment by Lincoln Law (JIRA) @eeckstein,@belkadan Any Help? |
There are other problems in the source code, which I found just by inspection. For example, there is no explicit lifetime handling for bufferConverter in decodeloopHandler(). It is passed as unsafe pointer to the callback (Why this is not reported by ASAN is a different question). Also, even with -Onone, but with ASAN enabled I get the wrong behavior. I don't see a compiler problem here. |
lincolnlaw (JIRA User), Did you figure out what the problem was? Should we mark this issue as resolved? |
Comment by Lincoln Law (JIRA) The function `AudioConverterFillComplexBuffer(converter, AudioBufferConverter.callback(), userinfo, &ioOutputDataPackets, &outputBufferList, nil)` |
Attachment: Download
Environment
Xcode10-beta3
Swift4.2
Additional Detail from JIRA
md5: 3de2b9861ae23ca337ae4cf30d30c63f
Issue Description:
As I create a new framework,
APlay: https://github.com/CodeEagle/APlay
I found out that. when I turn the optimization mode to -O or -OSize
It'll not work as none optimization level.
The text was updated successfully, but these errors were encountered: