Allegro 5 isn't working - c++

I have just started programming in allegro, but the first simple program i wrote to check it is in working order returns the error:
"Unhandled exception at 0x0F4C590B (allegro-5.0.7-monolith-md-debug.dll) in C++ Setup.exe: 0xC0000005: Access violation reading location 0x00000000."
I have looked for solutions but i cant find any, and yes, i have made sure it's 5.0.7 i have installed and linked to.
I have tried uninstalling and re-installing Allegro 5 and still do not know where the problem lies.

Access Violation errors are very rare and always related to the individual computer on which they occur. They are not errors in the ExpressMaintenance software but rather the result of something not functioning right on the system that causes the program to lose its place in memory. Usually an Access Violation results following some other error and it is the preceding error that is of significance.
Again, Access Violation errors are rare and always relate to the individual computer operating software or settings. The exact cause of the error can be difficult to find. Common causes typically are one one of the following:
Corrupt or insufficient version of Windows.
Insufficient RAM memory or system requirements.
Old or bad version of Microsoft Data Access Components (MDAC). See below.
Insufficient virtual memory allocated for large queries and data in memory.
Source

Related

How to use msvc asan with visual studio

I tried enabling asan in project->properties->c/C++->Enable Address Sanitizer (Experimental) : Yes (/fsanitize=address).
I can then build my project, but when running it breaks at
extern "C" void __cdecl _initterm(blah blah) in initterm.cpp with Exception thrown at 0x00007FFFCD3B2EB8 (ntdll.dll) in gnomes.exe: 0xC0000005: Access violation writing location 0x0000053747340000.
I've been told by others that this is a thing that happens, and I should continue through it. It then moves to ~50 or so other exceptions somewhere within ntdll.dll or other window api files, before eventually getting to my program, where it errors at the first line of main: GTApplication *app = new GTApplication(); (the first line of my main) with Access violation writing location blah.
So I'm unsure how to interpret this information. Is there something wrong with my foundational windows API layers on my computer? or is that just unavoidable (if weird) behavior.
And does that mean I should interpret the first line of my program as also just a quirk of using asan? or is there something wrong with the allocation of my application object?
Am I using asan incorrectly?
I am facing the same exact issue, while building 64-bit applications (looking at the size of pointers listed in messages, it's the same case for You), using VS 16.8.3. Even for an application, that does literally nothing (returns 0).
If possible, consider building 32-bit version of the application and checking, if the problem persists. ASan doesn't report such issues for me for 32-bit binaries.
Address Sanitizer in VS is still experimental, and support for x86-64 is even less mature, than for 32-bit x86.

Exception thrown at 0x00007FF93E507A7A (ntdll.dll) .Access violation reading location 0xFFFFFFFFFFFFFFFF

I'm using POCO lib to working network.
i use JSON data of POCO/JSON . my code:
User user(context.marshal_as<std::string>(tbUserName->Text),
context.marshal_as<std::string>(tbFullName->Text),
context.marshal_as<std::string>(tbDisplayName->Text),
context.marshal_as<std::string>(tbEmail->Text),
context.marshal_as<std::string>(tbPhoneNumber->Text),
context.marshal_as<std::string>(tbNamSinh->Text),
context.marshal_as<std::string>(tbPassword->Text),
context.marshal_as<std::string>(tbConfirm->Text)
);
string jsonString = user.serialize();
I have an error Exception thrown at 0x00007FF93E507A7A (ntdll.dll) in Client_Winform.exe:
0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
If there is a handler for this exception, the program may be safely continued.
Use Visual Studio's Code Analysis to track the exact place in your code where the bug is.
https://msdn.microsoft.com/en-us/library/ms182028.aspx
The problem with these kinds of error messages is not to understand the reason (bad handle) but to find the place. Since your code passed compilation with no errors, and in many cases, will run smoothly on several machines and crash only on one of them, you need to focus on the place of the crash.
You are using a handle which got returned as INVALID_HANDLE from some function (INVALID_HANDLE is -1 or 0xFFFFFFFFFFFFFFFF). When you try to use it, it gets used as an address and you don't have permissions to access that address (error 5 is access violation).
This could occur, when you do have multiplatform projects (i.e. assemblies). Meaning, if you do have one project of x86 and another project in x64. Issue occurs when you build project under wrong platform. For example, referred x64 assembly build under x86 and in the consumer code are trying to call specific function. Because, of this mixed platformed assemblies, reference calculation is resulting in x00000005 or xFFFFFFFF kind of location, which is restricted area in side RAM (i.e. OS part). Hence, it's throwing exception having message like "Access Violation exception reading location...". The solution I found is to identify and apply exact platform to relevant project. I retrieved entirely fresh code from the repo again and build under specific platform and this issue disappeared.
I was building a 10-year-old project with debug set as x64. When I changed to x86 for debug and Win32 in the configuration manager the "ntdll.dll can't find" error went away. Remaining issue is that malloc/free throws a runtime error is some places but not in others. Change to new/delete formats solved this issue.

atigktxx.dll in wxWidgets: "Access violation reading location 0xFEEEFEEE" (Release build)

I get the occasional access violation when I start my wxwidget application:
Unhandled exception at 0x0267894A (atigktxx.dll) in MyApp.exe: 0xC0000005: Access violation reading location 0xFEEEFEEE.
This is strange since is happens when I start the Release build. Shouldn't 0XFEEEFEEE point to uninitialized memory in Debug mode?
I usually get rid of the error by rebuilding my project (only).
So there's not really a chance to reproduce the error.
Has anyone come across this? I use wxGLCanvas widgets in my programm.
The first thing to do is to find out where exactly this access violation happens and you should be able to do this by choosing to break at Win32 exceptions when you run the program under debugger.
If it happens deep inside ATI OpenGL driver, it would seem to indicate yet another weirdness in ATI code and it wouldn't be the first one, e.g. it's also known to call CRT functions with invalid parameters.
OTOH it's also possible that you really pass an invalid parameter to some OpenGL function and in this case the stack backtrace should give at least some information about which function and which parameter it is.

Access violation at same program location

I am getting the error: Unhandled exception at 0x77d815de in client.exe: 0xC0000005: Access violation reading location 0x00000000.
I understand what the normal access violation error means, but this one keeps repeating itself at location 0x77d815de, as in, I'll delete lines of code in the program, and it breaks at location 0x77d815de, regardless of the line that is. The code I am running is the simple Windows API code, with some additions to the switch statements (which i have tried removing) and a class initialisation (Which again, i have also tried removing).
Could you please give me some suggestions on at least why there may be an overflow, or a way to fix this.
Thank you for your time.
--
Found it out, it was caused by two switch cases interlocking in a way unnoticable by the compiler, and me. Reverted it to an older form from my repository and it was fine. It caused corrupt data in the DirectX Device class, and screwed up some of the initialisations of it, causing the read exception.
I usually see those addresses in ntdll.dll. You are probably providing some bad data to the WinAPI and it's crashing because you are not using it correctly.
If you break into your debugger at this point, you should be shown the call stack. You can go back through it until you reach your own code where you made the call. From there, it should be much easier to find the problem.

C++ Any advice on tracking down Access Violations?

I've been having issues trying to track down an Access Violation in my program. It occurs when the destructor is called for the third time, exactly when the destructor appears to finish.
I've spent hours trying to track this down so I'm looking for further advice on things I can do. I'm creating the class instance with new and delete operators. The Visual Studio output window shows:
First-chance exception at 0x60e3ad84 (msvcp100d.dll) in WebCollationAgent.exe: 0xC0000005: Access violation writing location 0xabababab.
Unhandled exception at 0x60e3ad84 (msvcp100d.dll) in WebCollationAgent.exe: 0xC0000005: Access violation writing location 0xabababab.
Is there anything I can do to try and find out what was in those memory locations?
The call stack window shows the following (in reverse order as I've pasted it in to chronological order, earliest to latest):
Program.exe!Network::`scalar deleting destructor'() + 0x2b bytes C++
Program.exe!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::~basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >() Line 754 + 0xf bytes C++
Program.exe!std::_String_val<wchar_t,std::allocator<wchar_t> >::~_String_val<wchar_t,std::allocator<wchar_t> >() Line 478 + 0xb bytes C++
msvcp100d.dll!std::_Container_base12::_Orphan_all() Line 214 + 0x5 bytes C++
My best guess at this information is that there's some sort of string variable causing the issue? Does anyone have any advice on interpreting this information?
Any other pieces of advice would also be useful, thanks in advance.
I'm coding under Windows 7 and using Visual Studio 2010 Professional.
I've had success tracking memory bugs before using BoundsChecker (now part of Borland DevPartner). There are a number of similar products that might also help: HeapAgent, and Rational Purify. These seem to be much like ValGrind, but work on Windows.
Here are 3 open source alternatives that might assist:
DUMA (by the looks of it, you'll have to build it for Windows yourself, but the README contains some notes on doing that)
XMEM
elephant
I have no idea how these perform, but they sound very promising, and look like they all work on Windows in one way or another.
This Microsoft page on managing memory errors might also help, and also has links to setting Memory breakpoints, which might help you find out when your data is first being deleted or altered. Good luck!
Use the Microsoft Heap Debugging stuff and hope yours is one of the cases for which it was designed. Purify would be the next step after that.
It's built into Visual Studio and is helpful in some cases. If it works it sure beats giving IBM two or three pockets full of cash for Purify.
You can find the info here
TL;DR
In main, do this
int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
// Turn On (OR) - Keep freed memory blocks in the
// heap's linked list and mark them as freed
tmpFlag |= _CRTDBG_DELAY_FREE_MEM_DF;
// Turn on memory checking at each heap operation
tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF;
// Set the new state for the flag
_CrtSetDbgFlag( tmpFlag );
You can toggle the _CRTDBG_CHECK_ALWAYS_DF flag at different places if it runs too slow. However, I'd run it a few times with each heap op checked in order to get a feel for where the problem occurs.
I wrote this blog with some tips
http://www.atalasoft.com/cs/blogs/loufranco/archive/2007/02/06/6-_2200_Pointers_2200_-on-Debugging-Unmanaged-Code.aspx
The main thing you need to do is to get the crash or exception to happen while the code with the bug is still on the stack. A lot of times you get Access Violation some time after the code with the bug has executed and returned and it may actually be a long time later (in computer time). In that case, it's almost impossible to figure it out.
In your case, with the problem flagged in delete, it's a strong indicator that the heap is corrupt, and two common reasons in C++ are double-delete and mixing up array deletion (using delete when you should use delete[] or the other way around).
If you can reproduce it with simple code, I would look for the two problems above. Otherwise, download the Microsoft Debugging Tools and use gflags +hpa -i program.exe to make the heap much more sensitive to corruption (it will report the error much more quickly).