tondrej / chakracore-delphi

Delphi and Free Pascal bindings and classes for Microsoft's ChakraCore library

Home Page:https://tondrej.blogspot.com/search/label/chakracore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception of new object in multithreading

pony5551 opened this issue · comments

I uploaded a file!

ThreadDemo.zip

6

{$DEFINE SScript2} is normal!

I can confirm an access violation. Thanks for finding this, I'll post a new issue with a MCVE as there's too much unrelated code in your example. The issue can be reproduced regardless of multi-threading.

BTW this code is wrong:
RegisterMethod(AInstance, 'free', @TConsole.Free);

Any method you wish to register as a native callback must have the specific signature:
function(Args: PJsValueRef; ArgCount: Word): JsValueRef of object;

(as shown in the TConsole example).

I should probably make it clear in a comment or wiki.

Sorry, I used it wrong

RegisterMethod (AInstance, 'free' @ TConsole. Free);

Sorry, I used it wrong

RegisterMethod (AInstance, 'free' @ TConsole. Free);

No problem, and thanks for reporting.

Constructors of projected classes must be addref-ed to prevent them from being garbage-collected.
Thank you for finding and reporting it.

See TestFinalizer4 for a minimal example to reproduce the problem: simply call the script in a loop long enough until GC releases the constructor - . The next attempt to call the constructor will cause an access violation.

You may have to submit an issue to chakracore using c++

Sorry for being unclear. The issue was on the chakracore-delphi side (Pascal), and it's fixed now.

I see!thank you!

Welcome and thank you for your help.