You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are trying to port nodejs to iotjs in our project and we have developed a native addon which will interacting with the third party libraries.
Currently we are using N-API of iotjs to develop the native addon. But there is a major issue in N-API for triggering the callback from native to JS when there is any event triggered from third party library.
we have checked N-API async functionality using the napi_create_async_work with execute and complete.
But when there are multiple events are triggered from the third party library for same request napi_create_async_work design cant be used.
So we have taken alternate approach to handle this issue by using the uv_async_send.
With uv_async_send we are able to achieve the events triggering from native to JS .But there is any during the program exits and iotjs cleanup is called.
During the iotjs cleanup encountered the "ICE: Assertion 'JERRY_CONTEXT (jmem_heap_allocated_size) == 0"
Backtrace:-
Thread 1 "iotjs" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 #1 0x00007ffffe6608b1 in __GI_abort () at abort.c:79 #2 0x000000000057e9c3 in jerry_port_fatal (code=ERR_FAILED_INTERNAL_ASSERTION) at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-port/default/default-fatal.c:30 #3 0x000000000052800a in jerry_fatal (code=ERR_FAILED_INTERNAL_ASSERTION) at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/jrt/jrt-fatals.c:63 #4 0x000000000052805c in jerry_assert_fail (assertion=0x5b7b90 "JERRY_CONTEXT (jmem_heap_allocated_size) == 0",
file=0x5b7b40 "/home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/jmem/jmem-heap.c", function=0x5cc410 <func.23698> "jmem_heap_finalize", line=107)
at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/jrt/jrt-fatals.c:87 #5 0x0000000000527089 in jmem_heap_finalize () at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/jmem/jmem-heap.c:107 #6 0x0000000000526df5 in jmem_finalize () at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/jmem/jmem-allocator.c:170 #7 0x00000000004365eb in jerry_cleanup () at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/api/jerry.c:254 #8 0x000000000042095c in iotjs_terminate (env=0x7ef780 <current_env>) at /home/durgaprasad/work/iotjs/iotjs/src/iotjs.c:282 #9 0x0000000000420acb in iotjs_entry (argc=2, argv=0x7ffffffee448) at /home/durgaprasad/work/iotjs/iotjs/src/iotjs.c:318 #10 0x000000000041fe17 in main (argc=2, argv=0x7ffffffee448) at /home/durgaprasad/work/iotjs/iotjs/src/platform/linux/iotjs_linux.c:19
(gdb)
The text was updated successfully, but these errors were encountered:
This error means you didn't free up some memory. Usually the best way is capturing these with valgrind. I recommend to compile the project with 32 bit and system allocator: --target-arch=i686 --jerry-cmake-param=-DJERRY_SYSTEM_ALLOCATOR=ON --jerry-cmake-param=-DJERRY_CPOINTER_32_BIT=ON
Run valgrind with: --leak-check=full --show-leak-kinds=all
How can we trigger the callback from native addon to JS using n-api?
In my project I have a thread running in glib context and my JS code is running in UV context
Based on the request from JS i.e. from UV context native addon will trigger a request to thread in glib context.
Glib thread will respond asynchronously.
When I receive the data from the glibc thread context I need to make a callback to JS from native addon using the JS reference created during the request from UV context.
How can I achieve callback from native addon to JS using n-api asynchronously?
How can we integrate libtuv and Glib?
How can we support uv_prepare_start and uv_check_start functionality in libtuv
We are trying to port nodejs to iotjs in our project and we have developed a native addon which will interacting with the third party libraries.
Currently we are using N-API of iotjs to develop the native addon. But there is a major issue in N-API for triggering the callback from native to JS when there is any event triggered from third party library.
we have checked N-API async functionality using the napi_create_async_work with execute and complete.
But when there are multiple events are triggered from the third party library for same request napi_create_async_work design cant be used.
So we have taken alternate approach to handle this issue by using the uv_async_send.
With uv_async_send we are able to achieve the events triggering from native to JS .But there is any during the program exits and iotjs cleanup is called.
During the iotjs cleanup encountered the "ICE: Assertion 'JERRY_CONTEXT (jmem_heap_allocated_size) == 0"
Code snippet:-
NAPI_MODULE(query, init_query)
Backtrace:-
Thread 1 "iotjs" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007ffffe6608b1 in __GI_abort () at abort.c:79
#2 0x000000000057e9c3 in jerry_port_fatal (code=ERR_FAILED_INTERNAL_ASSERTION) at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-port/default/default-fatal.c:30
#3 0x000000000052800a in jerry_fatal (code=ERR_FAILED_INTERNAL_ASSERTION) at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/jrt/jrt-fatals.c:63
#4 0x000000000052805c in jerry_assert_fail (assertion=0x5b7b90 "JERRY_CONTEXT (jmem_heap_allocated_size) == 0",
file=0x5b7b40 "/home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/jmem/jmem-heap.c", function=0x5cc410 <func.23698> "jmem_heap_finalize", line=107)
at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/jrt/jrt-fatals.c:87
#5 0x0000000000527089 in jmem_heap_finalize () at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/jmem/jmem-heap.c:107
#6 0x0000000000526df5 in jmem_finalize () at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/jmem/jmem-allocator.c:170
#7 0x00000000004365eb in jerry_cleanup () at /home/durgaprasad/work/iotjs/iotjs/deps/jerry/jerry-core/api/jerry.c:254
#8 0x000000000042095c in iotjs_terminate (env=0x7ef780 <current_env>) at /home/durgaprasad/work/iotjs/iotjs/src/iotjs.c:282
#9 0x0000000000420acb in iotjs_entry (argc=2, argv=0x7ffffffee448) at /home/durgaprasad/work/iotjs/iotjs/src/iotjs.c:318
#10 0x000000000041fe17 in main (argc=2, argv=0x7ffffffee448) at /home/durgaprasad/work/iotjs/iotjs/src/platform/linux/iotjs_linux.c:19
(gdb)
The text was updated successfully, but these errors were encountered: