Page 1 of 1
EStringListError inside ConstructURL
Posted: 10.05.2017, 08:02
by DPStano
I'm getting this error callstack from multiple users anyone have idea whats wrong, connect is called in thread, each thread has own connection
Delphi 2009
EStringListError: List index out of bounds (1)
Classes: 0 TStringList.Get
Classes: 0 TStrings.Error
Classes: 0 TStringList.Get
Classes: 0 TStrings.IndexOfName
Classes: 0 TStrings.GetValue
ZURL: 435 TZURL.DoOnPropertiesChange
Classes: 0 TStringList.Changed
Classes: 0 TStringList.SetUpdateState
Classes: 0 TStrings.EndUpdate
Classes: 0 TStrings.SetTextStr
ZURL: 133 TZURLStringList.SetTextStr
ZDbcIntfs: 1389 TZDriverManager.ConstructURL
ZAbstractConnection: 722 TZAbstractConnection.ConstructURL
ZAbstractConnection: 849 TZAbstractConnection.Connect
Re: EStringListError inside ConstructURL
Posted: 11.05.2017, 20:49
by marsupilami
Hello DPStano,
to me this look like it either is a bug in the TStringList / TStrings or like a memory corruption. Most probably the latter one since exactly the same call succeeded two lines earlier.
Some databases (MySQL?) require you to have only one call to the connect method at a time. So it might make sense to make sure that only one thread calls the connect method of its TZConnection object at the same time.
With best regards,
Jan
Re: EStringListError inside ConstructURL
Posted: 16.05.2017, 11:20
by DPStano
it caused by calling Connect in thread maybe DriverManager should be protected by mutex or FURL should be method var or something like that
Re: EStringListError inside ConstructURL
Posted: 17.05.2017, 19:08
by marsupilami
Hello DPStano,
do you have a suggestion on hot to do that? Honestly I don't have much time for doing imporovements currently.
With best regards,
Jan
Re: EStringListError inside ConstructURL
Posted: 16.06.2017, 12:42
by DPStano
TZDriverManager as global object has to be threadsafe so all access to its private members has to be locked by some Lock TCriticalSection or some Mutex
i'd remove private FURL and add it as var in ConstructURL, ResolveDatabaseUrl, ResolveDatabaseUrl
FDrivers should not change during program runtime so it does need locking, probably
FLoggingListeners updates (AddLoggingListener,RemoveLoggingListener, HasLoggingListener) have to be locked
FLoginTimeout and FHasLoggingListener are atomic
Re: EStringListError inside ConstructURL
Posted: 18.06.2017, 14:11
by marsupilami
Hello DPStano,
could you possibly prepare a patch for this? I am still working on other bugs and don't have as much time for Zeos as I would like to have...
With best regards,
Jan
Re: EStringListError inside ConstructURL
Posted: 26.07.2017, 09:26
by DPStano
i'll let my implementation here, really do not know if it's absolutely correct but i do not have reported errors so far
https://gist.github.com/Sorien/fda8c65c ... e4dc7fd7b4
TLock just encapsulate TRTLCriticalSection