K
K
koi com2014-12-02 00:31:03
Delphi
koi com, 2014-12-02 00:31:03

How to fix Delphi error "Access viilation at adress 004190B8"?

Wrote a small test application in delphi using delphi 7. Never wrote in delphi before. The program solves the problem of synchronization of three processes. One generates random numbers and writes to the buffer, the second reads the numbers and calculates the square of each and writes them to another buffer, the third thread calculates the sum and outputs to Edit.
Window
55ea8105a91a4cddb659954394e8e190.png
When you click on the launch, the following message is displayed:
4586c760caf741f8879c80c82d026414.png
Already tried several methods from Google - it did not help. I'm running under Win 8.1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
evvcom, 2014-12-02
@evvcom

Victor Koltsov, of course, is right, but this is not the reason for this error. Judging by the "Write of address 0000000E" there is a record in the field of an object that does not exist, i.e. reference MyObject = nil. It is necessary to close the error window, then in the menu Search - Find Error... It is positioned on a line like MyObject.prop := value; or MyObject.SomeMethod(); carefully study the sequence of actions, understand why the assignment to MyObject := TMyObject.Create(); has not yet been completed by this point. (call constructor), well, fix it.
In addition, I will add something that is not obvious for a beginner: the third thread, which writes in Edit, is actually the first (or even zero, if counted from scratch), i.e. this is the main thread, the UI thread, because you need to work with VCL only from the main thread, but be careful not to hang the main UI thread when synchronizing its reading from the 2nd buffer with the thread that writes to this 2nd buffer.

V
Viktor Koltcov, 2014-12-02
@Vityarik

It is necessary to synchronize the streams before reading / writing to the buffers, so that only 1 stream works with the buffer at a time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question