35 Commits

Author SHA1 Message Date
Ivan FB
558356149b
better comments about where genBindings() should be invoked 2026-05-04 11:18:32 +02:00
Ivan FB
0305c1ace7
Fix cpp vulnerabilities
1. No timeout → wait_for + 30 s default (ffi/codegen/cpp.nim)
ffi_call_ now takes std::chrono::milliseconds timeout and uses cv.wait_for. All factory/method signatures carry a timeout parameter (default std::chrono::seconds{30}), mirroring the Rust blocking API.

2. Stack-allocated state → shared_ptr ownership (ffi/codegen/cpp.nim)
ffi_cb_ now receives a heap-allocated std::shared_ptr<FfiCallState_>* as user_data. The refcount is 2 going in (one for ffi_call_, one for the callback). If ffi_call_ times out and returns, its copy drops — but the state stays alive (refcount 1) until Nim eventually calls back and delete sptr in ffi_cb_ drops the last reference. No more stack UAF.

3. Destructor + Rule of 5 (ffi/codegen/cpp.nim, examples/nim_timer/nim_timer.nim)

Added nimtimer_destroy to nim_timer.nim with {.dynlib, exportc, cdecl, raises: [].} — joins the FFI and watchdog threads, frees the context
Codegen now always emits void {libName}_destroy(void* ctx) in extern "C" and generates a destructor, deleted copy ctor/assignment, and move ctor/assignment for the context class
timeout_ stored in the class; move transfers it, destructor uses it
4. Hardcoded TimerConfig in createAsync (ffi/codegen/cpp.nim)
createAsync now uses the actual ctorParams list (same as create), so it's correct for any library, not just nim_timer.

5. Opaque exceptions → clear error messages (ffi/codegen/cpp.nim)
deserializeFfiResult wraps nlohmann::json::parse + .get<T>() in a catch that rethrows as "FFI response deserialization failed: ...". The stoull in create() is also try-caught with "FFI create returned non-numeric address: " + raw.
2026-05-04 00:36:52 +02:00
Ivan FB
5305c20c22
simplify auto-generate cpp and rust 2026-05-03 23:45:49 +02:00
Ivan FB
8b75ae8b03
enhance async cpp
Co-authored-by: Copilot <copilot@github.com>
2026-05-03 17:33:06 +02:00
Ivan FB
f9d9a5237c
simplify Rust example
Co-authored-by: Copilot <copilot@github.com>
2026-05-03 16:54:53 +02:00
Ivan FB
a80f042f35
use proper case 2026-05-03 16:36:37 +02:00
Ivan FB
47f3422057
allow annotate type with ffi too 2026-05-03 16:23:00 +02:00
Ivan FB
9524108474
enhance cpp and rust tokio examples
Co-authored-by: Copilot <copilot@github.com>
2026-05-03 15:48:47 +02:00
Ivan FB
0c516f53aa
allow auto-generate cpp code and add example 2026-05-03 11:11:06 +02:00
Ivan FB
26bf173e2c
simplify ffi generation and add simple Rust example 2026-05-03 10:01:38 +02:00
Ivan FB
e3eca63236
first ci version (#12) 2026-04-29 23:48:36 +02:00
Ivan FB
df2277e726
Fix memleaks (#11)
* protect against mem leak in case of failures sending requests to ffi thread
* better cleanup if failures in createFFIContext
* avoid dangling cstring in handleRes under ARC/ORC
* better resource cleanup in destroyFFIContext
* invoke onNotResponding if failure in destroyFFIContext
* correct seq copy in alloc
* make sure the lock is init before cleanUpResources
* better possible exception handling in processReq
* guard allocSharedSeq if given seq is empty
* enhance error handling in ffi_context
* add new tests and some corrections
2026-04-27 21:22:45 +02:00
Pablo Lopez
bb8a3e7e22
fix: add install_name for mac (#8)
not to hardcode the paths
2026-02-20 17:37:13 +02:00
Igor Sirotin
c2c03f1f0f
chore: update license files to comply with Logos licensing requirements 2026-02-05 15:12:18 +00:00
Ivan Folgueira Bande
06111de155
properly importing and exporting chronicles v0.1.3 2026-01-23 17:55:43 +01:00
Ivan Folgueira Bande
d3fe7b4389
properly exposing chronicles and tables when importing ffi v0.1.2 2026-01-23 17:34:01 +01:00
Ivan Folgueira Bande
bb8ed28ab0
add require chronicles taskpools and import std tables v0.1.1 2026-01-23 15:01:08 +01:00
Ivan FB
9fff004b19
add explicit timeout when sending watchdog requests (#7) 2026-01-16 15:48:35 +01:00
Darshan
c2cc2d7ea1
identation error (#5) 2026-01-07 00:01:17 +05:30
Ivan Folgueira Bande
d7a5492121
avoid use gc ed types in FFIContext and better macro documentation 2025-12-13 23:53:59 +01:00
Ivan Folgueira Bande
6811c8675f
make registeredRequests no threadvar
This gives better results in logos-messaging-go-bindings
Can be shared across threads because is populated at compile-time
and only read at run-time.
2025-12-12 14:45:59 +01:00
Ivan Folgueira Bande
803744dd29
rm some Waku leftover references 2025-12-11 23:50:00 +01:00
Ivan FB
75251fb721
Merge pull request #1 from logos-messaging/extend-more
Complete first ffi macro definition
2025-12-11 17:26:01 +01:00
Ivan Folgueira Bande
5964e287a9
rm useless comments 2025-12-11 17:21:47 +01:00
Ivan Folgueira Bande
e0cf0c8842
fixes for proper proc exposure to c 2025-12-11 17:11:59 +01:00
Ivan Folgueira Bande
142a57f543
set logger in main thread body 2025-12-11 17:10:24 +01:00
Ivan Folgueira Bande
da3251aa1a
evolving more 2025-12-10 17:43:26 +01:00
Ivan Folgueira Bande
86dc58e7c2
add ffi macro 2025-12-09 18:51:50 +01:00
Ivan Folgueira Bande
b974eab39c
comment echo repr lines 2025-09-17 14:38:01 +02:00
Ivan Folgueira Bande
3c7f7f9a1c
remove comment 2025-09-17 14:37:53 +02:00
Ivan Folgueira Bande
a1a6536b3c
general ffi increments 2025-09-17 14:37:45 +02:00
Ivan Folgueira Bande
356f0ccc1b
working simplification 2025-09-17 14:37:36 +02:00
Ivan Folgueira Bande
46e51e45a6
more positive progress. Getting closer 2025-09-17 14:37:28 +02:00
Ivan Folgueira Bande
bbddf6925b
First commit 2025-09-17 14:37:11 +02:00
Ivan FB
04fd9f0f6d
Initial commit 2025-09-17 14:34:56 +02:00