View Full Version : Access Error (not) reporting
vcmohan
10th October 2005, 02:49
If I try to access any address beyond the frame size, I always get an access voilation error message. However if I create a buffer by new and go beyond its limit then I do not get an error message. (I am not using a try and catch in my plugin). Even if I try to access an address beyond the buffer, I am still able to view (through virtualdub) the entire clip properly processed. Only when I try to close the video file in vdub I get a system message which says sorry , encountered ... shutting down the application.
Why this happens?
WarpEnterprises
11th October 2005, 07:13
Did you try in both Release and Debug builds?
IanB
11th October 2005, 09:45
An Access Violation is caused by accessing a memory address for which windows has not allocated a page. When running beyond the edge of a buffer you might access an unmapped page or you might access some other piece of memory belonging to something else. In your case the latter is most likely and judging by the error you have corrupted something important.
It is ALWAYS extremly bad form to access memory addreses that are not explicitly yours.
WarpEnterprises
11th October 2005, 19:49
As a sidenote, I stumbled over a nice little tool calles "axe" (http://www.jbrowse.com/products/axe/ ) which can additionally "open" the memory of a process and can be quite useful to analyze files (it has a nice grafical memory display).
Fizick
11th October 2005, 21:26
IMHO, memory is sometimes allocated with a factor 1.5
vcmohan
13th October 2005, 03:48
Once again I have this problem of my post disappearing. Yesterday I posted a reply today its gone!
I know where in my code the access violation is occurring. I tried to access a location after converting a double to int and using it as the offset. I assumed that the rounding will be done to the lower integer, but it appears it is done to the nearest integer.
My question is incase of access violations in the Avisynth supplied frame buffer, the error is immediately reported. In case of buffer created using new, access violation is not reported immediately. The processing is done as i could run it in vdub by stepping forward or back or running. Only when I try to close the video file I get the error from system. Why is this access violation treated differently?
Fizick
13th October 2005, 19:11
Did you try to use OutputDebugString and DebugView utility?
vcmohan
14th October 2005, 06:54
Did you try to use OutputDebugString and DebugView utility?
Sorry I do not know what these are as I am a novice in C++ programming. I do not use debug facility since I have no documentation for it and so do the debugging my own hard way. I debugged my plugin. Its now ok and running. My question still is why these two access violations are treated differently?
WarpEnterprises
14th October 2005, 08:15
The message which comes when you close the file arises because someone (I don't know for sure) performs a check if your code has overwritten buffers (even if it happened in "your" memory space) and this is done when you FREE the memory (if it is not done in the program with delete or free then this happens automatically when the program terminates).
The first message comes if you try to access memory space which you don't possess.
There are some debug functions which can do this on demand. You can check the docu of _free_dbg and _malloc_dbg.
IanB
15th October 2005, 04:33
@vcmohan,
It's sort of random, VFB's being a large malloc usually get allocated at the end of the heap(no block large enough to reuse), so running off the end accesses pages that have never been mapped. Smaller mallocs may be able to reuse previously free'd memory, so running of the end accesses some other block of memory, and judging by the error message you are writing over the heap management structures which are just in front of every block that is malloc'd.
stickboy
15th October 2005, 04:47
My question still is why these two access violations are treated differently?Anything can happen when you invoke undefined behavior.
vcmohan
15th October 2005, 05:03
Anything can happen when you invoke undefined behavior.
I am not sure. I always get an access violation error if I over step the frame buffer supplied by Avisynth. In case of buffers I create with new, only at the time of delete I get a system error closing down the Virtualdub. These are not random behaviours.
In case of divide by zero I also found strange behaviour. Instead of reporting immediately, it processes ok, I return the frame, it is displayed in virtualdub and only when I step for next frame it is reported.
IanB
15th October 2005, 05:27
Try "new"ing up ten 1Mb chunks. Delete the first 9. Now new an eleventh 1Mb chunk.
Now run off the end of the eleventh chunk. -> no apparent error.
Now run off the end of the tenth chunk. -> access violation.
For more understanding print out the value of all the pointers (cast to an int) returned by the new.
Richard Berg
16th October 2005, 02:56
If you want to be certain that access violations are always caught, turn on PageHeap.
http://support.microsoft.com/Default.aspx?kbid=286470
stickboy
16th October 2005, 05:53
I am not sure. I always get an access violation error if I over step the frame buffer supplied by Avisynth. In case of buffers I create with new, only at the time of delete I get a system error closing down the Virtualdub. These are not random behaviours.I'm not saying it's random. I'm saying that when you step into the territory of undefined behavior, the compiler is free to generate whatever code it wants to.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.