Skip to content

resolved issue #141 about AccessViolations whith multithreading by ap…#150

Open
csm101 wants to merge 1 commit intoonryldz:masterfrom
csm101:master
Open

resolved issue #141 about AccessViolations whith multithreading by ap…#150
csm101 wants to merge 1 commit intoonryldz:masterfrom
csm101:master

Conversation

@csm101
Copy link

@csm101 csm101 commented Dec 23, 2022

…plying corrections suggested by @CaptainNemo07.

changes are:

  1. uses one static RTTIContext instead of continuing creating and destroying local RTTI Context
  2. uses a CriticalSection to protect all Superobject methods, since RTTI is clearly not ok with multithreading.
  3. point 1 indirectly fixes some bugs in the original code: in some places the local RTTIContext freed in a Except sction instead of a finally section.

I declared both the critical section and the RTTIContext as a private class variables contained in TBase (they have to be declared in the "interface" section of the unit to be used inside the code of generic classes: they can't be declared as plain global variables inside the implementation section of the unit because of how the delphi compiler implements generic classes when they get instantiated)

See the issue to find two test programs (one posted by me) that will cause for sure those concurrency problems. Let me point out that without this fix XSuperobject is totally unusable in a windows based rest server subject to multiple concurrent requests from hundreds of clients (which was my case)

(honest question: is this project still being maintained? A project like this seriously needs unit test cases with 99% code coverage...)

…g by applying corrections suggested by @CaptainNemo07.

(there were also some TRTTIContexts that were wrongly Freed in "except" sections instead of "finally" sections)
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

Successfully merging this pull request may close these issues.

2 participants