Where does "External Access Violation" come from mostly? lazarus / 31-LCL ---------------------------------------------------------------------- egsuh · 2024-06-05 05:11 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. ---------------------------------------------------------------------- Thaddy · 2024-06-05 05:51 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. ---------------------------------------------------------------------- MarkMLl · 2024-06-05 05:54 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). MarkMLl ---------------------------------------------------------------------- cdbc · 2024-06-05 05:59 Hi 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  ...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 ---------------------------------------------------------------------- egsuh · 2024-06-05 06:29 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. ---------------------------------------------------------------------- cdbc · 2024-06-05 06:59 Hi Come to think of it... I once had a run-in with the memory-manager and managed types; If you have managed types(strings, arrays & interfaces) and suddenly cut off the connection to the memory-manager in charge, you'll hear that kind of screamin' from your machine, when the compiler tries to free memory      It's kinda fun, just you try and remove the memory-manager in a running application... Regards Benny ---------------------------------------------------------------------- egsuh · 2024-06-05 07:09 Not easy to do anything... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TCustomGrid.WndProc(var TheMessage: TLMessage);begin  {$ifdef GridTraceMsg}  TransMsg('GRID: ', TheMessage);  {$endif}  case TheMessage.Msg of    LM_HSCROLL, LM_VSCROLL:      if csDesigning in ComponentState then        exit;    {$IFDEF MSWINDOWS}    // Ignore LM_SIZE while another sizing is being processed.    // Windows sends WM_SIZE when showing/hiding scrollbars.    // Scrollbars can be shown/hidden when processing DoOnChangeBounds.    LM_SIZE:      if gfUpdatingSize in FGridFlags then        exit;    {$ENDIF}  end;  inherited WndProc(TheMessage);  if not (FGridState in [gsColMoving, gsRowMoving]) then //For sure if MouseUp event is lost    FreeAndNil(FScroller);        // <===================  the error comes from here. end; ---------------------------------------------------------------------- MarkMLl · 2024-06-05 07:22 Expect a problem if fScroller is only one of several references (pointers) to the instance being freed. MarkMLl ---------------------------------------------------------------------- cdbc · 2024-06-05 07:59 Hi Quote  if not (FGridState in [gsColMoving, gsRowMoving]) then //For sure if MouseUp event is lost     FreeAndNil(FScroller);        // <===================  the error comes from here. Is this your doing or Lazarus' ?!? Regards Benny ---------------------------------------------------------------------- egsuh · 2024-06-05 08:15 Quote from: cdbc on June 05, 2024, 09:59:40 amHi Quote  if not (FGridState in [gsColMoving, gsRowMoving]) then //For sure if MouseUp event is lost     FreeAndNil(FScroller);        // <===================  the error comes from here. Is this your doing or Lazarus' ?!? Regards Benny This is Lazarus. unit Grids. ---------------------------------------------------------------------- cdbc · 2024-06-05 08:54 Hi Then look further up/before in /your/ code(since you're the only one with the problem, it's safe to assume it's in your code, not lazarus'). Regards benny ---------------------------------------------------------------------- egsuh · 2024-06-05 09:48 Quote from: cdbc on June 05, 2024, 10:54:10 amHi Then look further up/before in /your/ code(since you're the only one with the problem, it's safe to assume it's in your code, not lazarus'). Regards benny Yes, I agree. But it's really interesting, as the error occurs ONLY WHEN the TVALUELISTEDITOR is FOCUSED (and I try to close the internal classes). When the focus is moved away by clicking other control, then no problem. I'm trying to move the focus away in program, but not successful yet. I have employed various methods. ---------------------------------------------------------------------- MarkMLl · 2024-06-05 10:02 Quote from: egsuh on June 05, 2024, 11:48:41 amYes, I agree. But it's really interesting, as the error occurs ONLY WHEN the TVALUELISTEDITOR is FOCUSED (and I try to close the internal classes). When the focus is moved away by clicking other control, then no problem. I'm trying to move the focus away in program, but not successful yet. I have employed various methods. Only when the control is focused will anything be interested in the state of the scrollbar. MarkMLl