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

Multithread - Access violation when a json is deserialized #77

Closed
daviladanielc opened this issue Oct 31, 2023 · 3 comments
Closed

Multithread - Access violation when a json is deserialized #77

daviladanielc opened this issue Oct 31, 2023 · 3 comments

Comments

@daviladanielc
Copy link

I'm experiencing an access violation issue when there is a high level of concurrency with multithreading. I have a service that receives JSON data to insert a record into a database table. I'm using Neon to deserialize the JSON and map it to a class.

When I receive a request in my service, I handle it like this:

TTask.Run(
  procedure
  begin
    TPersistencia.Insert(StompFrame.Body, FConf, StompFrame, Self.FStompClient);
  end
);

In my tests, I sent the exact same JSON 1000 times, and occasionally, during the execution of the process, an access violation occurs when TNeonDeserializerJSON attempts to read the JSON to populate the class:

LReader := TNeonDeserializerJSON.Create(LConfig);
LReader.JSONToObject(LClasseTabela, LJSON);  //<< AV occurs here

If I remove TTask, it works fine but is slower, and I need it to be faster. How can I address this problem?

Here is the callstacks of Delphi:
image

@daviladanielc
Copy link
Author

I tried using TMonitor within a TCriticalSection when LReader is executed, but the problem persists.

@paolo-rossi
Copy link
Owner

Hello @daviladanielc ,

thank you for taking the time to file this issue...

Can build a small test case that reproduce the issue? thanks!

Paolo.

@paolo-rossi
Copy link
Owner

No additional info, probably it's been fixed along issue #83. Closing.

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

2 participants