(SOLVED) unhandled EAccessViolation-Error after program closes!? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Nukualofa · 2015-12-03 17:41 Hey, I have a very strange problem: I'm writing a multiplayer-online-game adaption of Settlers of Catan, and what already works is that one person can open a server and others can connect to the server. When the server-guy clicks on the Start- Game-Button, everyone gets the main game board window (in the attachment I replaced it with a simple form that's doing nothing, because the error is occuring then as well). When you close that form and all the other forms, an error occurs. If you don't click the Start-Game-Button and close all the forms, the error doesn't occur. To make matters even more strange, the error seems to occur only if there is just one player. The error message looks like this: An unhandled exception occured at $0040E575 : EAccessViolation : Access violation  $0040E575  $0040ACC2  $00469F01 FREENODE, line 1496 of avglvltree.pas  $00469F01 FREENODE, line 1496 of avglvltree.pas  $00469ED6 TAVGLVLTREE__FREEANDCLEAR, line 1505 of avglvltree.pas  $004BCD35 TRESOURCECACHE__CLEAR, line 367 of lclrescache.pas  $004BCD70 TRESOURCECACHE__DESTROY, line 373 of lclrescache.pas  $0040ACC2  $0044D96E CALLINTERFACEFINALIZATIONHANDLERS, line 843 of lclproc.pas  $00414BE0 FREEWIDGETSET, line 2080 of forms.pp  $00413AC8 INTERFACES_finalize, line 40 of interfaces.pp  $0040D138 To reproduce the error, run the program and click the button "Spiel eröffnen", change the value of the spinedit "Spielerzahl" to 1, click the button "Spiel eröffnen" and then the button "Spiel starten". Then close all the forms. I try to solve this problem for a couple of days already, so any idea is welcome! Thanks for your time! ---------------------------------------------------------------------- howardpc · 2015-12-03 18:42 The error pops up in avltree, but is nothing to do with that code. Look at your NetworkThread unit, the startGame method. Player is a dynamic array, so indexed from zero. But your enumerator, i, starts at 1. So your player[ i]:=TSpieler.Create... should be 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 player[i-1] :=TSpieler.Create... and the reihenfolge:=player[1].getName should presumably be 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 reihenfolge:=player[0].getName;  There may be other errors, but those changes should remove at least one access violation. ---------------------------------------------------------------------- Nukualofa · 2015-12-03 19:49 That's it! Thank you so much!