Unhandled exception at 0x ... in xxxx.exe:0xc0000005:access violation reading location 0x .....

Source: Internet
Author: User


unhandled exception at 0x ... in xxxx.exe:0xc0000005:access violation reading location 0x .....
For C + + beginners or careless people, it is easy to commit the error as shown:


So what is the cause of the error?
There is no doubt that there is only one, that is, reading a value or address that should not have been.
so how to solve it?
First thing, check if the parameters you passed are legal;
The second thing, if malloc has a piece of memory, you must remember free;
The third thing is whether you have assigned values or addresses that have been overrun.
To illustrate:
porg = Pcpicyuvorg->getlumaaddr (); for (y = 0, y < height-1; y++) {for (x = 0; x < width-1; x + +) {Pel a[4];//2x2a[ 0]=PORG[X]; A[1]=PORG[X+1]; a[2]= (Porg+stride) [x]; a[3]= (Porg+stride) [X+1];if (a[0]==255 && a[1]==255 && a[2]==255 && a[3]==255) {porg[x] = 255; PORG[X+1] = 255; (porg+stride) [x] = 255; (porg+stride) [x+1] = 255;} ELSE{PORG[X] = 0;porg[x+1] = 0; (porg+stride) [x] = 0; (porg+stride) [x+1] = 0;} x + = 1;} porg + = 2*stride;}

This code will appear with the error shown. So how to solve it?
porg = Pcpicyuvorg->getlumaaddr (); for (y = 0, y < HEIGHT/2; y++) {for (x = 0; x < width-1; x + +) {Pel a[4];//2x2a[ 0]=PORG[X]; A[1]=PORG[X+1]; a[2]= (Porg+stride) [x]; a[3]= (Porg+stride) [X+1];if (a[0]==255 && a[1]==255 && a[2]==255 && a[3]==255) {porg[x] = 255; PORG[X+1] = 255; (porg+stride) [x] = 255; (porg+stride) [x+1] = 255;} ELSE{PORG[X] = 0;porg[x+1] = 0; (porg+stride) [x] = 0; (porg+stride) [x+1] = 0;} x + = 1;} porg + = 2*stride;}

Obviously, the reason for the error is that the value of the overflow has been assigned.
If you encounter similar problems in the future, you can gradually check the above mentioned "three things" can be.






Unhandled exception at 0x ... in xxxx.exe:0xc0000005:access violation reading location 0x .....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.