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

remove remaining unsafe usage of sf_open #3720

Merged
merged 12 commits into from
Jun 21, 2018
Merged

remove remaining unsafe usage of sf_open #3720

merged 12 commits into from
Jun 21, 2018

Conversation

mossheim
Copy link
Contributor

@mossheim mossheim commented May 12, 2018

See prev work in #3683

Fixes #3673, fixes #3719.

After the big PR awhile ago there were still some uses of libsndfile's sf_open function that didn't handle Unicode strings for the Windows FS API. This cleans that up.

Moved common logic to the SC_SndFileHelpers header so there are fewer ifdefs everywhere.

Fixed spots are:

  • supernova's sndfile backend, buffer manager, and plugin interface
  • scsynth's NRT and b_read-related commands
  • Qt soundfileview's soundfile loading

some of the refactoring also touched the sclang soundfile primitives

@mossheim mossheim added comp: scsynth comp: sclang sclang C++ implementation (primitives, etc.). for changes to class lib use "comp: class library" comp: Qt GUI sclang Qt components -- for IDE tickets, use "env: SCIDE" instead comp: supernova labels May 12, 2018
@mossheim
Copy link
Contributor Author

although we currently don't offer supernova for windows, better to fix this now while it's fresh in my mind. it's easy to confirm at a glance that nothing is changing on non-windows platforms here. will try to put together some tests later today.

@mossheim mossheim requested a review from jamshark70 May 12, 2018 21:39
mossheim added 9 commits May 12, 2018 15:57
use windows sndfile includes in SC_SndFileHelpers, so that ifdef-wrapped code elsewhere can be eliminated
to get rid of ifdefs elsewhere
use wrapper to support utf8 filenames
for C++ libsndfile header
if we don't do this then windows doesn't get access to wchar func
@jamshark70
Copy link
Contributor

Hey! Thanks for putting this in so quickly. And thanks for the tip for the review, but I'm not really sure what I can say about it. My C++ is by far not good enough to analyze it by reading, and I don't have a Windows build environment, so I can't test.

I'll be happy to run it if someone can provide me with a build.

@mossheim
Copy link
Contributor Author

I created a branch on this repo for it with the same branch name as this, so the build is available on S3. Thanks for taking a look at it.

Copy link
Contributor

@jamshark70 jamshark70 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried in Windows with a filename "你好120336__cemagar__living-room-amb.wav" --

  • Buffer.read works fine!

  • SoundFileView, in this build, can't open any file, whether it contains special characters or not. It fails with both the above filename, and "319418__braleven__small-water-spill.wav"

@patrickdupuis patrickdupuis added this to the 3.10 milestone May 17, 2018
@mossheim
Copy link
Contributor Author

SoundFileView, in this build, can't open any file, whether it contains special characters or not. It fails with both the above filename, and "319418__braleven__small-water-spill.wav"

Thanks for taking a look, I'll fix it soon. :)

@mossheim
Copy link
Contributor Author

@jamshark70 Should work now, I tested it locally.

The problematic line was

auto name = filename.toStdWString().c_str();

After the call to c_str(), the object resulting from toStdWString() is destroyed, which leaves name a dangling pointer.

@jamshark70
Copy link
Contributor

Should work now, I tested it locally.

OK, I can't test unless these are pushed into the branch on the main repository. But I didn't see any other problems when I tried the earlier appveyor build, so I guess this is OK.

@mossheim
Copy link
Contributor Author

Ok, I'll do that later today, but you could also push it yourself now and get the build, since you have owner privileges.

@jamshark70
Copy link
Contributor

I've pushed 4e69c9d into the supercollider/supercollider issue/3673 branch, waited for appveyor to succeed, and downloaded again from http://supercollider.s3.amazonaws.com/builds/supercollider/supercollider/win32/issue3673-latest.html. It reverted to f1f6ae7 (previous commit), so my test result is the same as before.

So I tried downloading by hash: http://supercollider.s3.amazonaws.com/builds/supercollider/supercollider/win32/SC-4e69c9d0a3ba76ad21125a391c35f6263b22b8d7.zip

<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>CC1F14EE3ED4D67A</RequestId><HostId>wpoAt7bnRrAJEyB4KEslOeXvjgQdfJ697ZKM7Q331dEaStxRpe8ETepB/erax4ePAY2N6ySIs+Q=</HostId></Error>

So I am unable to test.

@mossheim
Copy link
Contributor Author

mossheim commented Jun 19, 2018

I've pushed 4e69c9d into the supercollider/supercollider issue/3673 branch, waited for appveyor to succeed, and downloaded again from http://supercollider.s3.amazonaws.com/builds/supercollider/supercollider/win32/issue3673-latest.html. It reverted to f1f6ae7 (previous commit), so my test result is the same as before.

If you have time, check again; it appears to be fine now.

So I tried downloading by hash: http://supercollider.s3.amazonaws.com/builds/supercollider/supercollider/win32/SC-4e69c9d0a3ba76ad21125a391c35f6263b22b8d7.zip

Sorry, my documentation on the wiki is wrong -- the correct URL would be http://supercollider.s3.amazonaws.com/builds/supercollider/supercollider/win32/SC-Windows-x86-4e69c9d0a3ba76ad21125a391c35f6263b22b8d7.zip. Thanks for pointing out the broken link!

@jamshark70
Copy link
Contributor

OK, that's better... it seems browser caching kept redirecting to the old zip.

Anyway, it passes my testing. Buffer reading and SoundFileView both work with Chinese-character paths now.

@mossheim
Copy link
Contributor Author

Great, thank you! Hopefully that's the last of these issues.

@mossheim mossheim merged commit d23b4ac into supercollider:develop Jun 21, 2018
@mossheim mossheim deleted the issue/3673 branch June 21, 2018 22:12
@mossheim mossheim restored the issue/3673 branch April 10, 2020 18:52
@mossheim mossheim deleted the issue/3673 branch August 1, 2020 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: Qt GUI sclang Qt components -- for IDE tickets, use "env: SCIDE" instead comp: sclang sclang C++ implementation (primitives, etc.). for changes to class lib use "comp: class library" comp: scsynth comp: supernova
Projects
None yet
3 participants