node-ctypes 2.13.1 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,85 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.14.0] - 2026-11-15
11
+
12
+ ### Added
13
+
14
+ - **`Version.libffi`**: the version of the libffi node-ctypes is built with
15
+ (`ffi_get_version()`), for example `"3.8.1"`.
16
+
17
+ ### Changed
18
+
19
+ - **Callbacks on hardened Linux**: libffi is built as its `configure` does on
20
+ Linux x86-64 and AArch64, with static trampolines and `memfd_create`.
21
+ - The code of a callback now comes from a table inside `ctypes.node`, mapped
22
+ read and execute: closures no longer need a page that is writable and
23
+ executable. When the table cannot be mapped, libffi falls back to the
24
+ dynamic trampolines.
25
+ - In that fallback, when writable and executable pages are refused (SELinux,
26
+ PaX, Memory-Deny-Write-Execute), libffi maps an anonymous memory file
27
+ twice instead of looking for a temporary file in `TMPDIR`, `/tmp`,
28
+ `/var/tmp`, `/dev/shm` or `HOME`. Before, a process with no directory both
29
+ writable and executable (a read-only container running as a regular user,
30
+ for example) could not create callbacks: `Failed to allocate FFI closure`.
31
+ - `ctypes.node` now imports `memfd_create` (glibc 2.27), within the glibc
32
+ 2.28 baseline of the Linux binaries; musl has had it since 1.1.20.
33
+
34
+ ### Fixed
35
+
36
+ - **`ffi_closure` layout on macOS ARM64**: the generated `ffi.h` chose the
37
+ layout of `ffi_closure` with `FFI_EXEC_TRAMPOLINE_TABLE`, a macro of
38
+ `fficonfig.h` that it does not include. node-ctypes, and the libffi sources
39
+ that include `ffi.h` first, saw a 48-byte closure with `cif` at offset 24,
40
+ while the closure allocator and `ffi_prep_closure_loc` used the 40-byte
41
+ layout with `cif` at 16, as the header generated by Autotools does. The
42
+ header now tests the platform itself (macOS ARM64), so every source sees the
43
+ same layout. Callbacks were not affected: node-ctypes only allocates a closure
44
+ (48 bytes were enough) and never reads its fields.
45
+ - **`FFI_TYPE_LONGDOUBLE` where `long double` is a `double`**: the generated
46
+ `ffi.h` kept it distinct from `FFI_TYPE_DOUBLE` everywhere, while libffi's
47
+ `configure` makes them equal unless `long double` is larger (not on macOS
48
+ ARM64 nor with MSVC). On AArch64 libffi would then have treated an 8-byte
49
+ `long double` as the 128-bit type. The header now applies the same rule, from
50
+ the compiler's `__LDBL_MANT_DIG__` and `__DBL_MANT_DIG__`. node-ctypes does
51
+ not use `long double` yet, so nothing changes for existing code.
52
+
53
+ ## [2.13.2] - 2026-11-15
54
+
55
+ ### Fixed
56
+
57
+ - **libffi 3.8.1**: the submodule moves from upstream commit `d02afc25` to the
58
+ v3.8.1 tag, with two fixes that node-ctypes could reach on ARM64:
59
+ - a struct larger than 16 bytes (other than an HFA) passed by value after the
60
+ integer registers, after a narrow stack argument on macOS (stack arguments
61
+ are packed there) or with `_align_ = 16` elsewhere, had the pointer to its
62
+ copy in a misaligned stack slot: the C function read another address and
63
+ could crash ([GHSA-h52h-3759-xqm4](https://github.com/libffi/libffi/security/advisories/GHSA-h52h-3759-xqm4)).
64
+ The tests skipped on Darwin ARM64 for this limitation run again;
65
+ - on macOS ARM64, with more than 1024 live callbacks, some orders of
66
+ `release()` wrote into a freed trampoline table
67
+ ([GHSA-23hx-9rxv-9qfp](https://github.com/libffi/libffi/security/advisories/GHSA-23hx-9rxv-9qfp)).
68
+
69
+ The other fixes of the release concern types node-ctypes does not expose
70
+ (`long double`, vectors) or platforms and APIs it does not use. The generated
71
+ headers report 3.8.1.
72
+
73
+ ### Documentation
74
+
75
+ - **Guides**: the reference sections of the README moved, unchanged, to
76
+ `guides/` (libraries and functions, types, structures, memory, callbacks,
77
+ asynchronous calls, errors, Windows API, TypeScript, Python ctypes parity,
78
+ building and testing), also published on the documentation site. The README
79
+ keeps the quick start, the supported platforms and the list of guides. New
80
+ pages: Getting started (installation, supported platforms, building from
81
+ source), Coming from Koffi (the Koffi API mapped to node-ctypes) and
82
+ Performance (results of the Koffi comparison, with charts, and how to run
83
+ it). The paragraph on direct calls now describes the register-frame calls.
84
+ - **Benchmark charts**: `npm run bench:charts -- report.json` writes static
85
+ SVG charts (ratio summary and one chart per workload group, light and dark)
86
+ from the JSON report of `bench:koffi` or `bench:ffi` (`--output`), into
87
+ `guides/images/` or the `--out` directory.
88
+
10
89
  ## [2.13.1] - 2026-11-14
11
90
 
12
91
  ### Fixed
@@ -1117,7 +1196,7 @@ number, not string`).
1117
1196
 
1118
1197
  2.0 aligns node-ctypes with Python ctypes as closely as the language allows,
1119
1198
  so that Python code can be ported with only the changes JavaScript requires.
1120
- It contains breaking changes: see [Migrating from 1.x](README.md#migrating-from-1x).
1199
+ It contains breaking changes: see [Migrating from 1.x](guides/python.md#migrating-from-1x).
1121
1200
 
1122
1201
  ### Breaking changes
1123
1202
 
@@ -1431,7 +1510,9 @@ It contains breaking changes: see [Migrating from 1.x](README.md#migrating-from-
1431
1510
 
1432
1511
  Initial releases.
1433
1512
 
1434
- [Unreleased]: https://github.com/dmazzella/node-ctypes/compare/v2.13.1...HEAD
1513
+ [Unreleased]: https://github.com/dmazzella/node-ctypes/compare/v2.14.0...HEAD
1514
+ [2.14.0]: https://github.com/dmazzella/node-ctypes/compare/v2.13.2...v2.14.0
1515
+ [2.13.2]: https://github.com/dmazzella/node-ctypes/compare/v2.13.1...v2.13.2
1435
1516
  [2.13.1]: https://github.com/dmazzella/node-ctypes/compare/v2.13.0...v2.13.1
1436
1517
  [2.13.0]: https://github.com/dmazzella/node-ctypes/compare/v2.12.2...v2.13.0
1437
1518
  [2.12.2]: https://github.com/dmazzella/node-ctypes/compare/v2.12.1...v2.12.2