Closed dotX12 closed 11 months ago
Hello,
Thank you for troubleshooting the matter!
FYI, SongRec doesn't run into the issue on Linux as the thread stack size is manually modified (https://github.com/marin-m/SongRec/blob/0.3.3/src/utils/thread.rs#L3), and we had previous Win32-compatible builds that worked.
If moving these buffers from the stack to the heap improves Win32 compatibility in certain cases then I guess that a PR could be welcome.
Regards,
Hello, thank you for implementing song recognition for Rust!
After analyzing the code and how it works, I decided to run the code and ran into a problem...
The error me encountering, "thread 'main' has overflowed its stack," typically occurs in Rust when there's too much data being allocated on the stack. In Rust, each thread has a fixed-size stack (commonly around 1-2 MB on many systems), and program exceeds this limit, me encounter a stack overflow.
Problem code
In this code, a stack overflow occurs if run in the main thread.
Fix
Replacing fixed-size arrays with vectors in SignatureGenerator structure in Rust is a significant change that affects memory management and the way data is accessed
Original Structure
Static Arrays
ring_buffer_of_samples
,reordered_ring_buffer_of_samples
,fft_outputs
, andspread_fft_outputs
are implemented as fixed-size arrays.Modified Structure
Dynamic Vectors
Vec<i16>
andVec<f32>
), which are dynamic arrays with sizes that can be modified during runtime.I tested the code and it works the same, I don't see any overflow errors anymore. If you are ready to accept these changes, I can open a PR.