Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible exceptions in UCommon.pas initialization and deadlock in finalization #245

Open
SkybuckFlying opened this issue Jan 27, 2022 · 0 comments

Comments

@SkybuckFlying
Copy link
Contributor

SkybuckFlying commented Jan 27, 2022

Potentially unsafe code:

UCommon.pas:

initialization
MinTimeStampDateTime:= StrToDateTime('1980-01-01 00:00:000', IntlDateTimeFormat);

GMainThreadNotify := TThreadNotify.Create ( TThread.CurrentThread ); // unit initialization runs in main thread

Exception handling code is not yet in place. Both lines of code can be problematic.
If system format for time and date change this may cause a problem with parsing from string to date and time.

Also

finalization
FreeAndNil(GMainThreadNotify);

Could dead lock on waiting and throwing an exception, me wonders if exception handling is still in place for finalization sections:

"

This function can raise EXCEPTION_POSSIBLE_DEADLOCK if a wait operation on the critical section times out. The timeout interval is specified by the following registry value: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\CriticalSectionTimeout. Do not handle a possible deadlock exception; instead, debug the application.

If a critical section is deleted while it is still owned, the state of the threads waiting for ownership of the deleted critical section is undefined.

While a process is exiting, if a call to EnterCriticalSection would block, it will instead terminate the process immediately. This may cause global destructors to not be called.

"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant