This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM368 mp3enc crash

Using ti-dvsdk_dm365-evm_4_02_00_06 on DM368, MP3 encoder dm365_mp3enc_3_5_00. Audio sample rate is 48000Hz stereo, mp3 bit rate is 192kbps, input buffer size 4608, output buffer size 2048.

Very intermittently, a SIGSEGV will be raised during Aenc1_process function call.  Attempting to print stack trace from the signal handler only shows this:

0x1bf48 /usr/bin/myapp() [0x1bf48]
0x404137b0 /lib/libc.so.6(__default_sa_restorer_v2+0) [0x404137b0]

Any suggestions on how to debug this?

Edit: I found that the gcc option -mapcs-frame should be used when compiling to walk past default_sa_restorer, but mp3_enc_prod.a must not have that.

Edit: More info from using sigaction to handle the segfault:

trap_no=e error_code=17 oldmask=0
r0=4059f000 r1=ffffffff r2=49dd7440 r3=4015d034 r4=404f9494
r5=00000000 r6=404f9494 r7=00000000 r8=00000001 r9=40541240 r10=4015d034
fp=4015d044 ip=40541274 sp=49dd73a8 lr=00106a14 pc=0010637c cpsr=80000010

The pc points to ia_mp3_encoder_table_choose+0x40

  106378:       e59a0008        ldr     r0, [sl, #8]
  10637c:       e7906101        ldr     r6, [r0, r1, lsl #2]

The lr points to ia_mp3_encoder_count_bits+0x440
  106a10:       ebfffe4d        bl      10634c <ia_mp3_encoder_table_choose>
  106a14:       e5c60016        strb    r0, [r6, #22]

  • Here's a test case that reproduces the problem.  I need a fix for this ASAP.

    4062.mp3crash.tar.gz

  • Hello?  Can anyone at TI help me?

  • I found a workaround: The R1 register appears to be an index into a table, and it appear to be -1 (ffffffff).  After setting up a sigaction handler for the SIGSEGV signal, in this handler changing this register to zero before returning from the sigaction handler seems the mp3 encoder functions normally.  I have counted the handler called up to 5 times per encode of 1152 samples, so performance should not be affected much.

    The code looks like this:

    void sigactionHandler(int sig, siginfo_t *info, void *secret)
    {
        ucontext_t *uc = (ucontext_t *)secret;

        if (uc->uc_mcontext.arm_r1 == 0xffffffff) {
            uc->uc_mcontext.arm_r1 = 0; // mp3 crash, try to recover with different table index
            return;
        }
        // other diagnostics can go here
    }

    // install the signal handler
            struct sigaction sa;
            sa.sa_sigaction = sigactionHandler;
            sigemptyset(&sa.sa_mask);
            sa.sa_flags = SA_SIGINFO;
            sigaction(SIGSEGV, &sa, NULL);

    I hope workaround is helpful if anyone has the same problem, until a solution for the mp3 encoder is released.