How to debug SEGV_ACCERR

前端 未结 2 1412
半阙折子戏
半阙折子戏 2020-12-14 10:43

I have an app that streams video using Kickflip and ButterflyTV libRTMP

Now for 99% percent of the time the app is working ok, but from time to time I get a native s

2条回答
  •  旧巷少年郎
    2020-12-14 11:12

    By symptom/description of the problem, your program is most likely experiencing some sort of invalid memory access/corruption which is somehow related with multi-thread race condition scenario. From my past experience, debugging memory corruption itself is very difficult and if it is linked to multi-thread environment it becomes very very difficult. Some of my previous post might be helpful and provide some general guidelines on these topics. Please note that these posts are related to Windows/Linux and not for Android platform.

    cpp - valgrind - Invalid read of size 8

    A segmentation fault sometimes occurs when the function cvCreateFileCapture is invoked on network URL

    While reading further about similar issue and your code sinppet, I came across one post which is mentioned below:

    What does SEGV_ACCERR mean?

    Client code snippet of your application

    synchronized (mWriteFence) {
                    if (!mConnected) {
                        continue;
                    }
                    if (frame.getFrameType() == Frame.VIDEO_FRAME) {
                        writeResult = mRTMPMuxer.writeVideo(frame.getData(), frame.getOffset(), frame.getSize(), frame.getTime());
                        calcVideoFpsAndBitrate(frame.getSize());
    
                    } else if (frame.getFrameType() == Frame.AUDIO_FRAME) {
                        writeResult = mRTMPMuxer.writeAudio(frame.getData(), frame.getOffset(), frame.getSize(), frame.getTime());
                        calcAudioBitrate(frame.getSize());
                    }
    
    }
    

    From above code, it appears to me that if your application receives Frame.VIDEO_FRAME & Frame.AUDIO_FRAME in certain order it might be leading to some sort of race condition(may be async model implementation) while using the frame variable within RtmpMuxerMix.writeThread module.

    To conclude such issues:

    • we should try to read the documentation about library and its best practices and get your code reviewed. Sometime it helps to find out obvious problems in our logic.
    • We should try to reproduce this issue while running application under dynamics tools. I am not aware about such tools on Android platform. Please not that once we start running application under dynamics tools, sequence of execution gets changed and after that it is possible that we either be able to reproduce such issues very frequently or almost not be able to reproduce it.

    .

提交回复
热议问题