google / visqol

Perceptual Quality Estimator for speech and audio
Apache License 2.0
641 stars 118 forks source link

Seg fault caused by calling Visqol::VisqolApi::Measure #78

Closed MaksymT17 closed 1 year ago

MaksymT17 commented 1 year ago

I found that with a longer duration, longer than 10 seconds, an application with Visqol may crash with Seg Fault. The crash appears only when I use multiple threads, each of thread could run VisqolApi::Measure. GDB backtrace I caught several times

memcpy@@GLIBC_2.14 (vg_replace_strmem.c:1035) Visqol::AMatrix::AMatrix(absl... Visqol::VisqolApi::Measure:

And it is important in our use case. After reading documentation of Visqol and documented code I didnt see mentions that measure of MOS value can be used in multiple threads. Of course, I can add mutex or signal handler.

Just to be sure that I'm using Visqol API correctly, can we assume the current implementation of Visqol could be safely called from a single thread? with multiple threads, we would need to apply synchronization

mchinen commented 1 year ago

Thanks for sharing this issue. I believe ViSQOL should work for multiple threads. There is a lightweight test for this. However, I think it requires multiple instances of the VisqolManager or VisqolAPI classes. Can you clarify if you were reusing the same instance across multiple threads?

MaksymT17 commented 1 year ago

thanks for responding.

Yes, we use multiple instances of VisqolApi. Each thread creates a new Visqol::VIsqolApi instance for each measurement. The issue is intermittent. In some cases, the application runs for more than 15 mins before crashing

mchinen commented 1 year ago

I see. As far as I'm aware there is no global or singleton in visqol code itself, but possibly one of the libraries/dependencies have this. How many threads are you running? Is it possible that the crash is due to memory exhaustion? The dynamic warping/alignment steps are quite memory intensive.

MaksymT17 commented 1 year ago

I think that issue is related to the audio files being compared. In case data in wav file is incomplete, or header file is written wrongly such an issue may appear. At least reproduced only when some files were written wrongly.

I'm closing this issue, but we have to be aware if we will try to compare some unchecked or wrong audio files - visqol may produce a crash with Segmentation Fault.

Thanks @mchinen for your interaction.