How to handle runtime access violation exception
-
Hello there. I am trying to encode some audio to mp3 format using libavcodec. This small utility was working fine untill lately. Now it has started giving me this weird runtime
access violation reading location
exception. I am showing following code to give you an ideaint ret = avcodec_encode_audio2(mp3_codec_context, &pkt, frame, &got_output);
// WHERE
// typeof(mp3_codec_context) = AVCodecContext
// typeof(pkt) = AVPacket
// typeof(frame) = AVFrame
// typeof(got_output) = intWhen I debugged...I can see that none of the specified arguments are
NULL
. So, how do I know what is wrong and where ? Thanks for any input. -
Hello there. I am trying to encode some audio to mp3 format using libavcodec. This small utility was working fine untill lately. Now it has started giving me this weird runtime
access violation reading location
exception. I am showing following code to give you an ideaint ret = avcodec_encode_audio2(mp3_codec_context, &pkt, frame, &got_output);
// WHERE
// typeof(mp3_codec_context) = AVCodecContext
// typeof(pkt) = AVPacket
// typeof(frame) = AVFrame
// typeof(got_output) = intWhen I debugged...I can see that none of the specified arguments are
NULL
. So, how do I know what is wrong and where ? Thanks for any input.Well, Were the Working Dll's Upgraded recently. Because it worked in the past, but no longer now, that is a very distinct possibility. Regards, Bram.
Bram van Kampen
-
Hello there. I am trying to encode some audio to mp3 format using libavcodec. This small utility was working fine untill lately. Now it has started giving me this weird runtime
access violation reading location
exception. I am showing following code to give you an ideaint ret = avcodec_encode_audio2(mp3_codec_context, &pkt, frame, &got_output);
// WHERE
// typeof(mp3_codec_context) = AVCodecContext
// typeof(pkt) = AVPacket
// typeof(frame) = AVFrame
// typeof(got_output) = intWhen I debugged...I can see that none of the specified arguments are
NULL
. So, how do I know what is wrong and where ? Thanks for any input.An access violation is not only thrown when a memory pointer is
NULL
. Often NULL pointers are even allowed as arguments. In your case you have to check the members of the passed structures. See the documentation for the used function: FFmpeg: Encoding[^]. There is information about the structure members and links to the structure type descriptions. Note that you must not only check the buffer pointer members but also the size members and probably others. An access violation may for example occur when the size member indicates a size larger than the real buffer size. The above link indicates also that the function is deprecated. If you have upgraded to a new FFmpeg version, consider to use replacement functions. -
Hello there. I am trying to encode some audio to mp3 format using libavcodec. This small utility was working fine untill lately. Now it has started giving me this weird runtime
access violation reading location
exception. I am showing following code to give you an ideaint ret = avcodec_encode_audio2(mp3_codec_context, &pkt, frame, &got_output);
// WHERE
// typeof(mp3_codec_context) = AVCodecContext
// typeof(pkt) = AVPacket
// typeof(frame) = AVFrame
// typeof(got_output) = intWhen I debugged...I can see that none of the specified arguments are
NULL
. So, how do I know what is wrong and where ? Thanks for any input.You have pointers to structures AVPacket and AVFrame and got_output You may have 1.) Changed the structures 2.) Changed the compiler settings for packing of structures. Making the structure not what the DLL expects You sort of say get_output is an int but that isn't what the documentation says. Finally you have a return error in ret .... what does it return? Things like invalid parameter will tell you more.
In vino veritas