Forum > LCL

Where does "External Access Violation" come from mostly?

(1/3) > >>

I had recently encountered it, and solved it, and encounter it again in different setting. What's the likely cause? My brain is cluttered (as always) and cannot focus any more.

Usually it means that you asked a shared library to do something stupid, E.g. providing a parameter as an empty pchar without allocating memory for it, buffer overruns, mixing up by reference and by value, wrong calling convention, trying to pass pascal strings to a library written in another language, misaligned records, etc. It is usually not the shared library that is at fault, but the way the programmer tries to use it. This may also occur in OS provided shared libraries, like Windows dll's. Garbage in, garbage out.

Bad pointer, trapped by the (hardware) and operating system and reported to you rather than crashing the computer.

Complicated in the case of Object Pascal by the fact that strings, dynamic arrays etc. are accessed by pointers which have been initialised (and hopefully tidied up) implicitly, while (instances) of classes start off as a pointer containing rubbish which must be initialised manually (a .Create()) and then freed manually (Free) after which they must no longer be used (that's where FreeAndNil() is useful).


edit: Thaddy & Mark beat me to it...
The first obvious one would be: do you use libraries?!?
The second one would be: do you use external threads?!?
The third one would be: OS-api calls
OFC, these 3 can be 1 os-api-call in a library that creates a thread  :D
...and AVs are mostly to do with accessing memory/parts, that you don't have rights to, haven't created or have already free'd.
Regards Benny

I do not use libraries, self-created threads, ...

I use RTTI controls. Possibly this might be related.
Interesting thing is that when I close the form altogether there are no problem. Problem happens when I try to clear internal data only and reset. 
Even with the exception message, I can continue to run the application. Anyway I'll look into this more.


[0] Message Index

[#] Next page

Go to full version