Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [1.0.16] - 2026-04-16

### Fixed

- **WASM crash in `cloudsync_set_column` on existing rows**: Calling `cloudsync_set_column(table, col, 'lww', 'block')` on a table with pre-existing rows crashed the WASM build with a `RuntimeError: function signature mismatch` as soon as the block-index migration tried to allocate memory. `block_init_allocator` was casting `cloudsync_memory_alloc` (a `uint64_t size` function) directly to the fractional-indexing allocator's `void *(*)(size_t)` slot. The cast is a no-op on native platforms where `size_t` is 64-bit, but WASM's `call_indirect` enforces strict type checking — the function is registered as `(i64) -> i32` and called as `(i32) -> i32`, triggering an immediate runtime error. A thin `fi_malloc_wrapper` (mirroring the existing `fi_calloc_wrapper`) now bridges the signatures. Native builds are unaffected.

## [1.0.15] - 2026-04-16

### Fixed
Expand Down
8 changes: 7 additions & 1 deletion src/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,20 @@ block_list_t *block_split(const char *text, const char *delimiter) {

// MARK: - Fractional indexing (via fractional-indexing submodule) -

// Wrapper for malloc: fractional_indexing expects size_t (32-bit on WASM) but cloudsync_memory_alloc takes uint64_t.
// A direct cast passes strict call_indirect type checking in WASM and triggers a RuntimeError.
static void *fi_malloc_wrapper(size_t size) {
return cloudsync_memory_alloc((uint64_t)size);
}

// Wrapper for calloc: fractional_indexing expects (count, size) but cloudsync_memory_zeroalloc takes a single size.
static void *fi_calloc_wrapper(size_t count, size_t size) {
return cloudsync_memory_zeroalloc((uint64_t)(count * size));
}

void block_init_allocator(void) {
fractional_indexing_allocator alloc = {
.malloc = (void *(*)(size_t))cloudsync_memory_alloc,
.malloc = fi_malloc_wrapper,
.calloc = fi_calloc_wrapper,
.free = cloudsync_memory_free
};
Expand Down
2 changes: 1 addition & 1 deletion src/cloudsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
extern "C" {
#endif

#define CLOUDSYNC_VERSION "1.0.15"
#define CLOUDSYNC_VERSION "1.0.16"
#define CLOUDSYNC_MAX_TABLENAME_LEN 512

#define CLOUDSYNC_VALUE_NOTSET -1
Expand Down
Loading