drowe67 / freedv-gui

GUI Application for FreeDV – open source digital voice for HF radio
https://freedv.org/
GNU Lesser General Public License v2.1
206 stars 52 forks source link

error Assertion `nout <= freedv_get_n_max_speech_samples(f)' failed. #106

Closed netmate1234 closed 3 years ago

netmate1234 commented 3 years ago

freedv: /home/martin/temp/freedv-gui/codec2/src/freedv_api.c:823: freedv_bits_to_speech: Assertion `nout <= freedv_get_n_max_speech_samples(f)' failed. Aborted (core dumped)

(Running 2020. It comes often, Ubuntu 20.10. FreeDV 1.5.2 dev.)

drowe67 commented 3 years ago

Pls see https://github.com/drowe67/freedv-gui/issues/107 suggestions (1) and (2)

drowe67 commented 3 years ago

Closed as no response from OP

netmate1234 commented 3 years ago

I removed 3 assserts in codec2. now its stable.

drowe67 commented 3 years ago

Removing asserts is a bad idea - they are there to trap unexpected and illegal behavior.

drowe67 commented 3 years ago

@tmiw :point_up: this might be related to what Kanda is reporting :thinking:

drowe67 commented 3 years ago

@timw I popped this into the top of freedv_rx and the assert fired:

    fprintf(stderr, "max_speech_samples: %d max_modem_samples: %d\n", 
        freedv_get_n_max_speech_samples(freedv), freedv_get_n_max_modem_samples(freedv));
    {
        int nout = 2*freedv_get_n_max_modem_samples(freedv);
        assert(nout <= freedv_get_n_max_speech_samples(freedv));
    }

I think I know what's going on here:

  1. When we are out out sync (and squelch is off), we run through that pass through code, the input modem samples are oversampled up to the 16 kHz speech sample rate so we can hear the off air rx audio.
  2. When the demod is out of sync it will just ask for the nominal number of input samples, which satisfies the assert.
  3. However if we fall out of sync, it's possible nin might be set to max_modem_samples on the last modem frame processed before we fall out of sync. Doesn't look like there is enough storage for that case, so the assert fires.
  4. I haven't been able to reproduce the actual issue, as it requires a few conditions to line up, but can see how it might happen from analysis. Just in 2020 I suspect.
drowe67 commented 3 years ago

OK by forcing nin to be the max in freedv_rx.c:

        nin = freedv_nin(freedv);
        nin = freedv_get_n_max_modem_samples(freedv);
        /* optionally read some stats */

I can also trigger another assert (I have seen this once before):

./src/freedv_tx 2020 ~/LPCNet/wav/all.wav - | ./src/cohpsk_ch - - -20 | ./src/freedv_rx 2020 - /dev/null -v
<snip>
freedv_rx: /home/david/codec2/src/fdmdv.c:1770: fdmdv_8_to_16: Assertion `(n % FDMDV_OS) == 0' failed.

I hit that once before.

tmiw commented 3 years ago

@drowe67, I assume the PR fixes that additional assert as well?

drowe67 commented 3 years ago

I think this one was fixed with https://github.com/drowe67/codec2/pull/176