From c22aac17a2e2c702f769cdc3307cf2ef1d2a7870 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Fri, 29 Mar 2024 10:21:49 -0600 Subject: [PATCH] More debugging of bad write sizes --- dependencies/lmdb/libraries/liblmdb/mdb.c | 7 ++++++- package.json | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dependencies/lmdb/libraries/liblmdb/mdb.c b/dependencies/lmdb/libraries/liblmdb/mdb.c index bdfece657..a4cf42055 100644 --- a/dependencies/lmdb/libraries/liblmdb/mdb.c +++ b/dependencies/lmdb/libraries/liblmdb/mdb.c @@ -4468,6 +4468,10 @@ mdb_page_flush(MDB_txn *txn, int keep) for (n=1; n<=pagecount; n++) { dp = dl[n].mptr; dl_nump[n] = IS_OVERFLOW(dp) ? dp->mp_pages : 1; + if (dl_nump[n] < 0) { + fprintf(stderr, "Invalid page count %i at index %i for page no %i\n", dl_nump[n], n, dl[n].mid); + return MDB_BAD_TXN; + } pgno_t p = dl[n].mid + dl_nump[n]; if (p > pgno) pgno = p; @@ -4551,6 +4555,7 @@ mdb_page_flush(MDB_txn *txn, int keep) pos = pgno * psize; size = psize; nump = dl_nump[i]; + mdb_tassert(txn, nump > 0); pages_written += nump; size *= nump; } @@ -4624,7 +4629,7 @@ mdb_page_flush(MDB_txn *txn, int keep) goto retry_write; fprintf(stderr, "Write error: %s position %u, size %u", strerror(rc), wpos, wsize); last_error = malloc(100); - sprintf(last_error, "Attempting to write page at position %u, size %u", wpos, wsize); + sprintf(last_error, "Attempting to write page at position %u, size %u, blocks %u, buffer sizes %i %i %i", wpos, wsize, n, iov[0].iov_len, iov[1].iov_len, iov[2].iov_len); } else { rc = EIO; /* TODO: Use which error code? */ DPUTS("short write, filesystem full?"); diff --git a/package.json b/package.json index b3325bf14..aff0269cc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lmdb", "author": "Kris Zyp", - "version": "3.0.3", + "version": "3.0.3-debug.1", "description": "Simple, efficient, scalable, high-performance LMDB interface", "license": "MIT", "repository": { @@ -68,7 +68,7 @@ "prebuild-win32": "prebuildify-platform-packages --debug --target 20.0.0 && prebuildify-platform-packages --debug --target 18.17.1 && set ENABLE_V8_FUNCTIONS=false&& prebuildify-platform-packages --debug --napi --platform-packages --target 18.17.1", "prebuild-libc-arm7": "ENABLE_V8_FUNCTIONS=false prebuildify-platform-packages --debug --napi --platform-packages --tag-libc --target 18.17.1", "prebuildify": "prebuildify-platform-packages --debug --napi --target 18.17.1", - "full-publish": "cd prebuilds/win32-x64 && npm publish --access public && cd ../darwin-x64 && npm publish --access public && cd ../darwin-arm64 && npm publish --access public && cd ../linux-x64 && npm publish --access public && cd ../linux-arm64 && npm publish --access public && cd ../linux-arm && npm publish --access public && cd ../.. && npm publish && node util/remove-optional-deps.cjs", + "full-publish": "cd prebuilds/win32-x64 && npm publish --tag test --access public && cd ../darwin-x64 && npm publish --tag test --access public && cd ../darwin-arm64 && npm publish --tag test --access public && cd ../linux-x64 && npm publish --tag test --access public && cd ../linux-arm64 && npm publish --tag test --access public && cd ../linux-arm && npm publish --tag test --access public && cd ../.. && npm publish --tag test && node util/remove-optional-deps.cjs", "recompile": "node-gyp clean && node-gyp configure && node-gyp build", "test": "mocha test/**.test.js --expose-gc --recursive", "deno-test": "deno run --allow-ffi --allow-write --allow-read --allow-env --allow-net --unstable test/deno.ts",