access-violation

Why are so many errors "AccessViolationException"s?

I have seen many errors over the course of my computer-using life, and a lot of them seemed to be Access Violation Exceptions calling way out into non-readable memory or 0x00000000/0xFFFFFFFF. What sort of programming error causes this? is it intentional to get the program to crash when something goes very wrong? ...

AccessViolationException when serializing a struct of arrays of structs?

I have a sequential struct that I'd like to serialize to a file, which seems trivial. However, this struct consists of, among other things, 2 arrays of other types of structs. The main struct is defined as follows... [StructLayout(LayoutKind.Sequential)] public struct ParentStruct { [MarshalAs(UnmanagedType.ByValT...

access violation in WM_PAINT not caught

To test this problem I have written a minimal windows application. If I force an access violation in the WM_PAINT handler this exception never gets to the debugger. If started without debugger the access violation also does not show up. Usually you should get the Windows Error Reporting dialog. Digging a bit deeper it seems that somethi...

AV while iterating through hash_map?

_transaction is a private member variable of my class, declared as: public: typedef stdext::hash_map<wchar_t*, MyClass*, ltstr> transaction_hash_map; private: transaction_hash_map _transactions; During cleanup I am trying to iterate through this list and free up any objects still unfreed. However I am getting an AV on the for...

.Net 2.0: Help troubleshooting a System.AccessViolationException. 100% managed code.

This is kind of repeated from my previous question, although the objective of my question is completely different now. I'm getting, now and then, about once a week, only in my development machine, a System.AccessViolationException in a web app I made. Since my machine is having a few things that don't work quite well (like a blue scree...

Access Violation Reading Location on std::set::erase

I have recently caught the following crash in my application: m_players[0].erase(plr); -- CRASHES HERE m_players[1].erase(plr); m_players is declared as: set<PlayerPointer> m_players[2]; Visual Studio shows that it is "0xC0000005: Access violation writing location 0x0000000000000024." Compiler: Visual Studio 2008. Diassembly: 00...

Tracking down a AccessViolationException in WPF

I've written a WPF application that uses many Frame controls to view camera feeds. When deployed, it crashes pretty randomly (anywhere from 2 hours to 16+ hours), and I see these in the event log, consecutively: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other...

Can looking at freed memory cause an access violation?

Can accessing (for read only) memory freed cause an access violation, and, if so, under what circumstances? ...

Delphi: Access violation after calling function from external DLL (C++)

There's a function, written in C++ and compiled as DLL, which I want to use in my Delphi application. Scraper.cpp: SCRAPER_API bool ScraperGetWinList(SWin winList[100]) { iCurrWin=0; memset(winList,0,100 * sizeof(SWin)); return EnumWindows(EnumProcTopLevelWindowList, (LPARAM) winList); } Scraper.h: #ifdef SCRAPER_EXPORTS...

System.AccessViolationException with Dynamic Proxy Generation

We are using PostSharp to inject caching functionality, we are only seeing this issue when we are using it. When we use Spring the issue seems to go away. Any help would be appreciated as this, the issue is very difficult to replicate. I've included the stack trace below: Attempted to read or write protected memory. This is often an in...

Access violation when calling external function (C++) from Delphi application

I've an external DLL written in C++. The piece below declares a struct type and a function, which, being given a pointer, fills a variable of this type: enum LimitType { NoLimit, PotLimit, FixedLimit }; struct SScraperState { char title[512]; unsigned int card_common[5]; unsigned int card_player[10][2]; unsigned int ca...

Converting a function from Visual Basic 6.0 to C# is throwing AccessViolationException

I'm converting a function from Visual Basic 6.0 as: Declare Function RequestOperation Lib "archivedll" (ByVal dth As Long, ByVal searchRequestBuf As String, ByVal buflen As Long, ByVal FieldNum As Long, ByVal OP As Long, ByVal value As String) As Long In C#, I'm declare the function as: [DllImport("archivedll")] public static extern ...

Can I put try / catch around an OS API that crashes?

I use a Windows OS library to manipulate image files. Sometimes it crashes deep inside it for no apparent reason—all the inputs are reasonable and its not a threading issue. The crash is memory A/V. So, what are the down sides to something like this: try { pFoo = OsAPIThatCrashes(); } catch { pFoo = NULL; } Will that even work?...

Access Violation On Vista Startup

I occasionally get a strange unhandled access violation when my .NET application is started automatically on startup (using a shortcut in the "Startup" folder) by Windows Vista. I have not seen this error when I start the executable manually. It happens randomly and I have yet to be able to reproduce the issue reliably. Here's the mes...

Baseclass Virtual Destructor Access Violation

Sorry if this was asked already, but I had a hard time searching for destructor and access violation =) Here's C++ pseudo-code the scenario: In DLL1 (compiled with /MT) class A { public: virtual ~A() <== if "virtual" is removed, everthing works OK { } } class B : public A { public: __declspec( dllexport ) ~B() ...

Crazy Access Violation in C++ Builder 6

I have the following code, and for the life of me, I cannot understand why there would be an Access Violation exception? I even deleted all the OBJs, TDS etc files and put it into a new project, still the Access Violation occurs. Essentially, this code displays a TListView in a TFrame and is to show the various current times around the ...

Loading text from a file into a 2-dimensional array (C++)

I'm making a game and I have stored the map data in a 2-dimensional array of size [34][10]. Originally I generated the map using a simple function to fill up the array and saved this data to a file using the following code: ofstream myFile; myFile.open("map.txt"); for ( int y = 0 ; y < MAP_HEIGHT ; ++y ) { for ( int x = 0 ; x < MAP_WI...

Delphi: Why can I link this function statically but not dynamically?

I am currently writing a module which interfaces with a black box 3rd party DLL for a check scanner. I need to have the DLL functions loaded dynamically, and this is working for all but one function. The SetScanParameters function has a record structure as a parameter, which I believe is somehow interfering with the methodology I am usin...

How to convert a bitmap to int[]?

Hi there! I'm writing a program to do some image processing on the GPU. For this I'm using CUDA.Net, but unfortunaly the CUDA doesn't recognize the type byte, in which I was able to store the pixels information using this code: BitmapData bData = bmp.LockBits(new Rectangle(new Point(), bmp.Size), ImageLo...

Trying to use tcl threads on windows 7 results in access violation.

I'm trying to get this simple program to work on windows, but it crashes: unsigned (__stdcall testfoo)(ClientData x) { return 0; } int main() { Tcl_ThreadId testid = 0; Tcl_CreateThread( } I am using a makefile generated by cmake and linking against a version of Tcl 8.5.7 I compiled myself using Visual C++ 2008 express. It ...