Comments (6)
This seems very strange. Are you able to compile and run the simple_playback example?
I don't have an installation of 2019 readily available, but I can't see how this can possibly be happening...
Edit: I looked at the documentation for ZeroMemory and I think you're right. What an absolutely stupid thing to optimize away. How could they be so stupid? I will update this as soon as possible.
from miniaudio.
So I've been pondering your comment and I'm still a bit unsure. I understand from the documentation that ZeroMemory and memset can be optimized out (which I still think is incredibly stupid - nothing like safe programming). What I'm questioning is how you'd get a read violation in that API. Are you absolutely sure you're passing in the correct pointer? The compiler can't possibly be optimizing away the entire ma_device
object because it's used directly in the code below that line. My concern is that SecureZeroMemory()
may be working by coincidence rather than by design and that it could be masking a more important bug. Before blindly replacing ZeroMemory
with SecureZeroMemory
, I'd like to know if simple_playback works.
from miniaudio.
I tried compiling the examples with the same kind of settings, but it seems to not optimise away the device there.
Guess we will just fix the version we embed in out project with the SecureZeroMemory
, since it solves the problem (that only appears on this compiler) on our side :D
Feel free to close the issue, at least if someone else faces the problem, they know what they can do!
Oh, and apparently, memset being optimised out (dead store optimisation) seems to be a know problem in the crypto world. And one that is hard to fix. It might happen with any compiler when optimisation is enabled. With our project it seems to happen only with VS2019, but it's just luck :D Here is a very interesting recorded talk on the topic https://media.ccc.de/v/35c3-9788-memsad
from miniaudio.
By the way, in case you're interested, you can actually override MAL_ZERO_MEMORY with your own implementation instead of modifying mini_al.h directly. You would do something like this just above the implementation part of mini_al.h:
#if defined(_WIN32)
#define MAL_ZERO_MEMORY(p, sz) SecuredZeroMemory((p), (sz))
#endif
#define MINI_AL_IMPLEMENTATION
#inlcude <mini_al.h>
This saves you from having a modified version of mini_al lying around which is a bit messy.
In any case, I understand the idea of dead store optimizations, but it's just that it doesn't make sense that it would crash. The problem is more about sensitive data not being scrubbed. This is just not adding up to me - it feels like a more serious underlying bug somewhere else that's triggering it. I assume this crash is happening with Bonzomatic? I had a look at the code in FFT.cpp, but I can't see anything obvious on that end. Nor can I see any issues in miniaudio... I'm not sure what's going on...
Have you looked at a disassembly of the compiled code by the way?
from miniaudio.
Nice! Hadn't checked to see if MAL_ZERO_MEMORY could not be defined without being overwritten when including :D
It's indeed in Bonzomatic and in the FFT.cpp file. Cant see no problem there either, it's a pretty simple class. Static analysis finds nothing fishy, and it works fine with quite a few compilers and platforms.
According to where it crashes and after debugging to see the content of everything above that "zeroing of pDevice", it looks looks like everything else is working as it should and contains the right data. My conclusion was that maybe the whole pDevice was discarded by the compiler and never created for it appeared unused, leading to that "read access violation". I then supposed that forcing the compiler to realise pDevice is actually used would help :D And using the SecureZeroMemory apparently did the job of both guarantee it's zeroed, and have it realise it is not a dead variable.
Havent checked the disassembly yet (was scared by the pain of reading the result of a Release build), but I will have a look tonight.
from miniaudio.
I'm going to go ahead and close this one. I'm not convinced this is an issue with miniaudio directly, especially considering the examples seem to be working just fine.
from miniaudio.
Related Issues (20)
- Atomic operation failed right after initialization on Apple Mac M2 HOT 2
- OSX ma_context_init__coreaudio fails to open dylibs HOT 7
- Adding Vorbis in split version HOT 4
- Add possibility to work with signed 8-bit data HOT 1
- 3D Sound Coordinate System HOT 1
- Crashes in MMDevAPI.dll HOT 10
- Safari on iOS17 does not play audio after first touch HOT 8
- Inconsistent decoded frame count/length HOT 1
- Assertion `ma_device_get_state(pDevice) == ma_device_state_starting` fails on exit HOT 2
- No sound and MA_NO_RUNTIME_LINKING causes syntax errors on MacOS HOT 2
- Crash when changing default playback device. HOT 13
- mp3 trial and error significantly slows down ma_sound_init_from_file HOT 4
- change sound's pitch HOT 1
- macOS Sonoma Failed to load library: CoreFoundation.framework/CoreFoundation HOT 1
- compile error in Xcode for iOS HOT 5
- Possible regresion when compiling for Web with Emscripten HOT 2
- [bug] linking on armel fails HOT 3
- No 7.1 sound output HOT 8
- assertion `ma_device_get_state(pDevice) == ma_device_state_stopped` failed when `ma_device_start` in callback `ma_IMMNotificationClient_OnDefaultDeviceChanged` HOT 1
- Emscripten miniaudio fails to link with --closure=1 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miniaudio.