![]() |
Fehler "access violation" - keine Ahnung, warum...
Hallo zusammen,
ich habe eine Delphi Prozedur, die mir nach der Abarbeitung (nachdem der letzte Befehl ausgeführt wurde) eine "access violation at 0x004070e8: write at address 0x004abefc" rauswirft. Ich habe allerdings keine Ahnung, wo der Fehler her kommt (da er nach der Ausführung auftritt). So langsam bin ich echt am verzweifeln. Verstehe ich das richtig, dass irgendwo versucht wird, auf einen Speicherbereich zu schreiben, der nicht frei/unbekannt ist? Danke und Gruß Thomas |
AW: Fehler "access violation" - keine Ahnung, warum...
.. es mag ja sein, dass Du den Code auswendig kennst
Wir jedoch nicht. Grüße Klaus |
AW: Fehler "access violation" - keine Ahnung, warum...
Zitat:
Hier mal die Prozedur, die den fehler rauswirft:
Delphi-Quellcode:
procedure TForm1.btnstartmanipulationsClick(Sender: TObject);
var i: integer; y: integer; slFile: TStringlist; begin { Verbindungsaufbau } return := COM_TcpOpen(zeiger, ipAddress, port); { evtl. laufende Manipulationen stoppen und Stringlist initialisieren } return := COM_StopRbsManipulationReq(zeiger); slFile := TStringList.Create; try slFile.LoadFromFile(strfilename); y := 0; { Manipulationen an Box übertragen } for i := low(man1) to high(man1) do begin SetLength(manipulationlist, y+1); manipulationlist[y].TriggerType := strtoint(slFile[man1[i].zeile + 3]); manipulationlist[y].TriggerMode := strtoint(slFile[man1[i].zeile + 4])+1; manipulationlist[y].TriggerSource := strtoint(slFile[man1[i].zeile + 5]); manipulationlist[y].TriggerValue := strtoint(slFile[man1[i].zeile + 6]); manipulationlist[y].TriggerHysterese := strtoint(slFile[man1[i].zeile + 7]); manipulationlist[y].DelayValue := strtoint(slFile[man1[i].zeile + 8]); manipulationlist[y].DelayType := strtoint(slFile[man1[i].zeile + 9]); manipulationlist[y].SequenceNumber := strtoint(slFile[man1[i].zeile + 10]); manipulationlist[y].ManipulationType := strtoint(slFile[man1[i].zeile + 11]); manipulationlist[y].ManipulationDuration := strtoint(slFile[man1[i].zeile + 12]); manipulationlist[y].ManipulationDurationType := strtoint(slFile[man1[i].zeile + 13]); manipulationlist[y].ManipulationMode := strtoint(slFile[man1[i].zeile + 14]); manipulationlist[y].ManipulationTarget := strtoint(slFile[man1[i].zeile + 15]); manipulationlist[y].ManipulationTargetValue := 0; manipulationlist[y].ManipulationValue1 := strtoint(slFile[man1[i].zeile + 17]); manipulationlist[y].ManipulationValue2 := strtoint(slFile[man1[i].zeile + 18]); manipulationlist[y].ManipulationValue3 := strtoint(slFile[man1[i].zeile + 19]); // Einzelne Signalmanipulation speichern/hochladen zu Box return := COM_RbsManipulationReq(zeiger, manipulationlist[y]); y := y + 1; end; // Manipulationen starten return := COM_StartRbsManipulationReq(zeiger); finally slFile.Free; end; end; |
AW: Fehler "access violation" - keine Ahnung, warum...
Achja, wenn ich diese zeile auskommentiere, kommt der Fehler nicht:
Delphi-Quellcode:
return := COM_RbsManipulationReq(zeiger, manipulationlist[y]);
|
AW: Fehler "access violation" - keine Ahnung, warum...
Dieser Thread hat einen Vorgänger:
![]() Also ganz offensichtlich befüllst du nicht alle Member des Records Manipulationtag. Dadurch können die nicht-befüllten Member zufällige Werte annehmen, was dann zu einem Fehler in der DLL führen kann. |
AW: Fehler "access violation" - keine Ahnung, warum...
Spendier' der Komponente mal eine manipulationlist.LoadFromFile, dann dürfte der Fehler schneller gefunden werden.
|
AW: Fehler "access violation" - keine Ahnung, warum...
Zitat:
Hier ist quasi das komplette projekt drin und der Fehler tritt auch hier auf:
Delphi-Quellcode:
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type Manipulationtag = record TriggerType: byte; ///< Trigger 1: Identify whether the TriggerValue is an address or a value (0: trigger not active; 1: trigger at value; 2: trigger at address; 3: trigger at value cyclic; 4: trigger at address cyclic) TriggerMode: byte; ///< Trigger 1: Identify the trigger mode (1: '=='; 2: '!='; 3: '>'; 4: '<'; 5: '<='; 6: '>='; 7: 'edge') TriggerSource: longword; ///< Trigger 1: The trigger source is the signal which value is used to trigger TriggerValue: longword; ///< Trigger 1: The trigger value to compare with the trigger source value TriggerHysterese: longword; ///< Trigger 1: Trigger hysteresis identify the hysteresis at trigger mode "edge" DelayValue: word; ///< Delay to start the manipulation DelayType: byte; ///< The delay value type (0: events since sequence start; 1: cycles since sequence start; 2: ms since sequence start; 3: events since last manipulation; 4: cycles since last manipulation; 5: ms since last manipulation) SequenceNumber: byte; ///< Identify the position of this manipulation in a sequence. For trigger manipulations the sequence number is '0' ManipulationType: byte; ///< Identify the manipulation type (1: loss; 2: offset; 3: value; 4: factor; 5: drift - from n to m in p steps ; 6: ramp - from n to m in p steps ; 7: disable manipulation; 8: freeze; 9: ramp with hold final value - from n to m in p steps; 10: drift with hold final value - from n to m in p steps; 11: factor linear; 12: offset negative) ManipulationDuration: word; ///< Identify the duration of a manipulation (0 means infinite duration) ManipulationDurationType: byte; ///< Identify the unit of the duration (0: duration is given in events; 1: duration is given in cycles; 1: duration is given in ms) ManipulationMode: byte; ///< Identify the manipulation target type (1: frame; 2: PDU; 3: signal group; 4: signal; 5: ECU) ManipulationTarget: longword; ///< Identify the address or identifier of the element to manipulate ManipulationTargetValue: word; ///< Sets a parameter for the manipulated target (e.g. ecu index number ) ManipulationValue1: longword; ///< The value one of the manipulation (n) ManipulationValue2: longword; ///< The value two of the manipulation (m) ManipulationSteps: word; ///< The value three of the manipulation (p) end; type TForm1 = class(TForm) btnconnect: TButton; btndisconnect: TButton; btngetversion: TButton; lblstatus: TLabel; btnclose: TButton; btnstartmanipulation: TButton; btnstopmanipulation: TButton; btnchangemanipulation: TButton; txtvalue: TEdit; btnreadfile: TButton; Button1: TButton; procedure btnconnectClick(Sender: TObject); procedure btndisconnectClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure btnstartmanipulationClick(Sender: TObject); procedure btnstopmanipulationClick(Sender: TObject); private { Private-Deklarationen } public var { Public-Deklarationen } zeiger:Pointer; return:NativeUInt; ipAddress:ANSIString; port:smallint; tagmanipulation: Manipulationtag; tagmanipulation2: Manipulationtag; boolconnected: boolean; end; var Form1: TForm1; implementation {$R *.dfm} function COM_TcpOpen(var zeiger:Pointer; ipAddress:AnsiString; port:smallint): NativeUInt; stdcall; external 'HwCom.dll'; function COM_Close(zeiger:Pointer):NativeUInt; stdcall; external 'HwCom.dll'; function COM_RbsManipulationReq(zeiger:Pointer; manipulation:Manipulationtag): NativeUInt; stdcall; external 'HwCom.dll' name '_COM_RbsManipulationReq@112'; function COM_StartRbsManipulationReq(zeiger:Pointer): NativeUInt; stdcall; external 'HwCom.dll' name '_COM_StartRbsManipulationReq@4'; function COM_StopRbsManipulationReq(zeiger:Pointer): NativeUInt; stdcall; external 'HwCom.dll' name '_COM_StopRbsManipulationReq@4'; { Programmstart: Variablen initialisieren } procedure TForm1.FormCreate(Sender: TObject); begin lblstatus.Caption := ''; ipAddress:='192.168.1.15'; port := 1500; new(zeiger); zeiger := NIL; boolconnected := false; tagmanipulation.TriggerType:=0; tagmanipulation.TriggerMode:=1; tagmanipulation.TriggerSource:=0; tagmanipulation.TriggerValue:=0; tagmanipulation.TriggerHysterese:=0; tagmanipulation.DelayValue:=0; tagmanipulation.DelayType:=0; tagmanipulation.SequenceNumber:=0; tagmanipulation.ManipulationType:=3; tagmanipulation.ManipulationDuration:=0; tagmanipulation.ManipulationDurationType:=1; tagmanipulation.ManipulationMode:=4; tagmanipulation.ManipulationTarget:=123456; tagmanipulation.ManipulationTargetValue:=0; tagmanipulation.ManipulationValue1:=1000; tagmanipulation.ManipulationValue2:=0; tagmanipulation.ManipulationSteps:=0; end; { Signal manipulieren } procedure TForm1.btnstartmanipulationClick(Sender: TObject); begin return := COM_RbsManipulationReq(zeiger, tagmanipulation); return := COM_StartRbsManipulationReq(zeiger); end; { Manipulation stoppen } procedure TForm1.btnstopmanipulationClick(Sender: TObject); begin return := COM_StopRbsManipulationReq(zeiger); end; { Verbindungsaufbau } procedure TForm1.btnconnectClick(Sender: TObject); begin { Verbindungsaufbau zu Flexcon midget } return := COM_TcpOpen(zeiger, ipAddress, port); boolconnected := true; end; { Verbindungsabbau } procedure TForm1.btndisconnectClick(Sender: TObject); begin { Verbindungsabbau } return := COM_Close(zeiger); zeiger := NIL; end; end. |
AW: Fehler "access violation" - keine Ahnung, warum...
Bei diesem Zeiger steig ich nicht durch, bist Du sicher, dass das alles so richtig ist?
|
AW: Fehler "access violation" - keine Ahnung, warum...
Zitat:
Das komische ist, dass die komplette Prozedur eigentlich funktioniert (sie tut das, was sie soll). Aber ganz zum Schluss kommt der Fehler und stoppt die weitere Ausführung. |
AW: Fehler "access violation" - keine Ahnung, warum...
nach dem Fehler springt Delphi in ein Debug Fenster (CPU).
Dort wird folgendes angezeigt: 004070E8 F0FF4AF8 lock dec dword ptr [edx-$08] |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:46 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz