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

Timing issue loading DLLs #864

Closed
baffled opened this issue Jul 2, 2024 · 4 comments · Fixed by #865
Closed

Timing issue loading DLLs #864

baffled opened this issue Jul 2, 2024 · 4 comments · Fixed by #865

Comments

@baffled
Copy link
Contributor

baffled commented Jul 2, 2024

There is a potential timing issue if you start more than one connection at the same time, each creating a DefaultMessageFactory.

When discovering the QuickFix.FIXxx.dll libraries, LoadLocalDlls() kicks out the second (and any subsequent) thread to prevent it reloading the same assemblies into memory. But if the first thread has not finished iterating through all the libraries and exited the function, the second thread will end up querying a truncated list and won't have all the factories in its list. That leads to an incorrect BeginString error at runtime when parsing message groups (and took a load of tracking down).

Better to lock the DefaultMessageFactory.LoadLocalDlls() function to ensure it completes before the second thread hits the loadFlag test.

@gbirchmeier
Copy link
Member

gbirchmeier commented Jul 2, 2024

Thank you for reporting this! I see it in the code, and agree with your interpretation of the situation.

The original coder did implement a loadFlag to ensure that two threads wouldn't run this function concurrently... but, in line with your explanation, second/subsequent threads should be forced to wait until the first thread's call completes the task before they are allowed to return.

(Also, that @ variable in there is kind of gross and unnecessary.)

I've seen/heard this incorrect-BeginString error happen capriciously, but not in consistent ways that have made it easy to follow-up on. But I think this could be the cause! I'm very happy you tracked this down 👍 and I will try to get the fix in the next release (which shouldn't be too far off I hope)

@baffled
Copy link
Contributor Author

baffled commented Jul 2, 2024 via email

@gbirchmeier
Copy link
Member

Hey @baffled , did you ever take a look at my PR fix for this issue?

shacaco pushed a commit to shacaco/quickfixn-1 that referenced this issue Aug 4, 2024
gbirchmeier added a commit to gbirchmeier/quickfixn that referenced this issue Aug 27, 2024
@baffled
Copy link
Contributor Author

baffled commented Sep 2, 2024 via email

gbirchmeier added a commit to gbirchmeier/quickfixn that referenced this issue Sep 12, 2024
It was planned to go into 1.12.0, but didn't make it
gbirchmeier added a commit that referenced this issue Sep 13, 2024
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 a pull request may close this issue.

2 participants