Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to handle runtime access violation exception

How to handle runtime access violation exception

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Django_Untaken
    wrote on last edited by
    #1

    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 idea

    int 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) = int

    When 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.

    B J L 3 Replies Last reply
    0
    • D Django_Untaken

      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 idea

      int 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) = int

      When 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.

      B Offline
      B Offline
      Bram van Kampen
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • D Django_Untaken

        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 idea

        int 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) = int

        When 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.

        J Offline
        J Offline
        Jochen Arndt
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • D Django_Untaken

          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 idea

          int 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) = int

          When 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.

          L Offline
          L Offline
          leon de boer
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups