prepare / Espresso

☕ Bridge your C# soul to the power of Javascript (V8 Javascript Engine / NodeJs)
MIT License
60 stars 11 forks source link

Issue sending C# arrays to Javascript engine #38

Closed dpwhittaker closed 6 years ago

dpwhittaker commented 6 years ago

Repro: https://github.com/dpwhittaker/Espresso https://github.com/dpwhittaker/Espresso/commit/e4d020db09322bd8c348669761b27d23d7d75421

I added a test 3 to TestEspressoCore. Attempting to send an array of anything (test covers strings, also tried CLR objects) results in a segfault. Looks like the native side allocates an array of JsValue pointers, but does not allocate a JsValue for each entry. I allocated it on the CLR side (with new JsValue()), and stuck it in the keepAlive to keep it around (I know there's a memory leak there, just trying to make anything work), but still end up with an array of null's on the Javascript side.

I was unable to access the dropbox link with the precompiled dll's, so I built it myself. I also had some issues running the patcher on our locked-down PCs, so I believe I replicated the steps correctly, but I may have built node incorrectly. So please verify that this issue exists with the way you build node. It would be appreciated if the complete nuget package was built and regularly published to nuget.org or github releases to avoid these questions on whether all the dependencies were built correctly. If this test works fine on your box, please republish the node dll's (github releases is highly recommended).

I'm having trouble debugging into the Native side on node, so I'm having trouble tracking the issue past the C# code. Any help you can provide would be appreciated.

prepare commented 6 years ago

@dpwhittaker, Thank you for your report.

Yes, It is a bug!. and I am fixing it now

prepare commented 6 years ago

@dpwhittaker ,

The cpp/cs jsarray logic is fixed.

This is the result of 'Test3'.

espr_arr_fix

see detail in https://github.com/prepare/Espresso/commit/4662387d7faa8a9f1cd991d461e2727e7f45b72a


I test it with 'only-v8' edition (Espresso VE).

and only on Win64,

I drop a latest Espresso-VE (libespr.dll) for this

https://drive.google.com/open?id=0By55ijpaDeJ0OVRVenVuRkhWLWc

This is NOT 'node' edition (Espresso-ND). I will build the 'ND' edition later.

dpwhittaker commented 6 years ago

I still can't access that drive link. I think you need to create some type of sharing link, and this one is your private link.

prepare commented 6 years ago

@dpwhittaker,

I upload it again to the temp repo.

please see https://github.com/prepare/temp_share_files

dpwhittaker commented 6 years ago

Thanks, that worked. Though this is exactly what github releases is designed for :)