AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Ist der Thread schuld?

Ein Thema von Neutral General · begonnen am 14. Okt 2008 · letzter Beitrag vom 14. Okt 2008
Antwort Antwort
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#1

Ist der Thread schuld?

  Alt 14. Okt 2008, 20:53
Hi,

Delphi-Quellcode:
procedure TCellThread.Execute;
begin
  repeat
    Synchronize(DoCalculate);
    Synchronize(FAutomaton.Paint);
    inc(FAutomaton.FGen);
  until Terminated;
end;
Während dieser Thread seine Arbeit verrichtet (Ist jetzt erstmal egal was er genau tut), taucht nach kurzer Zeit folgendes Phänomen auf:

Ich erhalte bei einem einfachen Lesezugriff auf eine Variable eines Objekts eine Zugriffsverletzung:

Zitat:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 0044F989 in module 'Project1.exe'. Write of address 00000044'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
Das sieht ganz danch aus, als würde das Objekt nichtmehr existieren, bzw als wäre der Self-Pointer verbogen.

Sowas kann imo durch Threads passieren. Aber ich Synchronisiere doch alles. Warum passiert sowas? (es passiert übrigens auch wenn ich

inc(FAutomaton.FGen); auskommentiere.

Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
Apollonius

Registriert seit: 16. Apr 2007
2.325 Beiträge
 
Turbo Delphi für Win32
 
#2

Re: Ist der Thread schuld?

  Alt 14. Okt 2008, 20:57
Von wo erfolgt dieser Zugriff und wie wird die Objektinstanz erhalten?

Nebenbei bemerkt: Ist dieser Thread nicht ziemlich sinnlos? Da du alles synchronisierst, wird alles im Hauptthread ausgeführt.
Wer erweist der Welt einen Dienst und findet ein gutes Synonym für "Pointer"?
"An interface pointer is a pointer to a pointer. This pointer points to an array of pointers, each of which points to an interface function."
  Mit Zitat antworten Zitat
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#3

Re: Ist der Thread schuld?

  Alt 14. Okt 2008, 21:19
Hi,

Alsooo... Der Callstack:

Delphi-Quellcode:
TCellularAutomatonEx.SetWorld(0,2,$26FC63C)
TWatorObject.Move(???)
TWatorSimulation.Calculate
TCustomCellularAutomaton.DoOnCalculate(???)
TCellThread.DoCalculate
TCellThread.Execute
Ich glaube die Zeile ausgemacht zu haben, an der es passiert:

TWatorObject.Move:

Delphi-Quellcode:
// FWorld: Array of Array of Pointer;
FWorld[fy,fx] := Self;
Setter:

Delphi-Quellcode:
procedure TCellularAutomatonEx.SetWorld(y, x: Integer;
  const Value: Pointer);
begin
  FEgal := 24; // <--- AV
  // ...
end;
Ehm... Ja warum ich das in nem Thread mache wenn ich eh alles Synchronisiere... Ehm keine Ahnung
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:17 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz