robobun
3e6d792b62
Fix PostgreSQL index out of bounds crash during batch inserts ( #21311 ) ( #21316 )
...
## Summary
Fixes the "index out of bounds: index 0, len 0" crash that occurs during
large batch PostgreSQL inserts, particularly on Windows systems.
The issue occurred when PostgreSQL DataRow messages contained data but
the `statement.fields` array was empty (len=0), causing crashes in
`DataCell.Putter.putImpl()`. This typically happens during large batch
operations where there may be race conditions or timing issues between
RowDescription and DataRow message processing.
## Changes
- **Add bounds checking** in `DataCell.Putter.putImpl()` before
accessing `fields` and `list` arrays
(src/sql/postgres/DataCell.zig:1043-1050)
- **Graceful degradation** - return `false` to ignore extra fields
instead of crashing
- **Debug logging** to help diagnose field metadata issues
- **Comprehensive regression tests** covering batch inserts, empty
results, and concurrent operations
## Test Plan
- [x] Added regression tests in `test/regression/issue/21311.test.ts`
- [x] Tests pass with the fix: All 3 tests pass with 212 expect() calls
- [x] Existing PostgreSQL tests still work (no regressions)
The fix prevents the crash while maintaining safe operation, allowing
PostgreSQL batch operations to continue working reliably.
## Root Cause
The crash occurred when:
1. `statement.fields` array was empty (len=0) due to timing issues
2. PostgreSQL DataRow messages contained actual data
3. Code tried to access `this.list[index]` and `this.fields[index]`
without bounds checking
This was particularly problematic on Windows during batch operations due
to potential differences in:
- Network stack message ordering
- Memory allocation behavior
- Threading/concurrency during batch operations
- Statement preparation timing
Fixes #21311
🤖 Generated with [Claude Code](https://claude.ai/code )
---------
Co-authored-by: Claude Bot <claude-bot@bun.sh >
Co-authored-by: Claude <noreply@anthropic.com >
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com >
2025-07-25 12:53:49 -07:00
taylor.fish
07cd45deae
Refactor Zig imports and file structure (part 1) ( #21270 )
...
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-22 17:51:38 -07:00
pfg
83760fc446
Sort imports in all files ( #21119 )
...
Co-authored-by: taylor.fish <contact@taylor.fish >
2025-07-21 13:26:47 -07:00
Meghan Denny
875604a42b
safety: a lot more exception checker progress ( #20956 )
2025-07-16 00:11:19 -07:00
Jarred Sumner
89aae0bdc0
Add flag to disable sql auto pipelining ( #21067 )
...
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-07-15 01:13:35 -07:00
Ciro Spaciari
6efb346e68
feature(postgres) add pipelining support ( #20986 )
...
Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com >
2025-07-14 21:59:16 -07:00
Zack Radisic
ac61b1d471
Use better function names for bun.String ( #20999 )
2025-07-12 18:19:16 -07:00
Ciro Spaciari
aa06455987
refactor(postgres) improve postgres code base ( #20808 )
...
Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com >
2025-07-07 18:41:01 -07:00
Meghan Denny
068997b529
make node:dns,net,cluster,tls exception checker clear ( #20658 )
...
Co-authored-by: nektro <5464072+nektro@users.noreply.github.com >
2025-07-03 18:28:38 -07:00
Ciro Spaciari
964f2a8941
fix(fetch/s3) Handle backpressure when upload large bodies ( #20481 )
...
Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com >
2025-06-27 20:52:46 -07:00
Meghan Denny
b87cf4f247
zig: handle when coerceToInt32 and coerceToInt64 throw ( #20655 )
2025-06-25 20:44:13 -07:00
Meghan Denny
f9712ce309
make node:buffer,zlib,stream,fs exception checker clear ( #20494 )
2025-06-25 18:36:08 -07:00
190n
346e97dde2
fix bugs found by exception scope verification ( #20285 )
...
Co-authored-by: 190n <7763597+190n@users.noreply.github.com >
2025-06-18 23:08:19 -07:00
Meghan Denny
6b4662ff55
zig: .jsUndefined -> .js_undefined ( #20377 )
...
Co-authored-by: nektro <5464072+nektro@users.noreply.github.com >
2025-06-13 16:14:57 -07:00
Meghan Denny
dedd433cbf
zig: prefer .jsUndefined() over .undefined for JSValue ( #20332 )
2025-06-12 13:18:46 -07:00
Jarred Sumner
773484a628
Split uSockets/uWS <> Zig bindings into many different files ( #20138 )
...
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com >
2025-06-02 02:10:57 -07:00
Meghan Denny
284de53f26
safety: audit and add missing exception checks to JSC::constructArray+constructEmptyArray ( #20119 )
2025-05-31 20:05:02 -07:00
Jarred Sumner
3ea6133c46
CI: Remove unused top-level decls in formatter in zig ( #19879 )
...
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com >
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
2025-05-23 22:49:48 -07:00
pfg
00a3cbd977
more child-process ( #18688 )
...
Co-authored-by: pfgithub <6010774+pfgithub@users.noreply.github.com >
2025-05-06 22:12:24 -07:00
Dylan Conway
a0819e9d02
fix more node:timers tests ( #19432 )
...
Co-authored-by: 190n <ben@bun.sh >
2025-05-02 20:50:02 -07:00
Dylan Conway
465379d96a
add Timeout.prototype.close, _idleTimeout and _onTimeout ( #19318 )
2025-04-28 00:25:25 -07:00
chloe caruso
80aff24951
fix: require.extensions uses Strong instead of being clever ( #19231 )
2025-04-23 17:52:41 -07:00
chloe caruso
3349c995b5
no usingnamespace, organize jsc namespace, enable -fincremental ( #19122 )
...
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com >
2025-04-22 16:34:15 -07:00
Ciro Spaciari
a512ad5155
fix(sql) fix flush ( #19177 )
2025-04-21 22:21:55 -07:00
chloe caruso
7d7512076b
remove more usingnamespace ( #19042 )
2025-04-17 19:04:05 -07:00
chloe caruso
4ec410e0d7
internal: make @import("bun") work in zig ( #19096 )
2025-04-17 12:32:47 -07:00
chloe caruso
be77711a4e
delete usingnamespace in bindings generator ( #19020 )
2025-04-15 12:14:47 -07:00
Jarred Sumner
879fdd7ef6
Bump Zig again ( #18948 )
2025-04-11 19:13:20 -07:00
Jarred Sumner
ec87a27d87
Introduce Bun.redis - a builtin Redis client for Bun ( #18812 )
2025-04-08 03:34:00 -07:00
Jarred Sumner
ed410d0597
Move DataCell into separate file ( #18849 )
2025-04-07 20:06:31 -07:00
Jarred Sumner
11f2b5fb55
Run zig fmt
2025-04-03 12:04:24 -07:00
Jarred Sumner
4806e84cc1
Revert "remove many usingnamespace, introduce new ref count and ref leak debugging tools ( #18353 )"
...
This reverts commit a199b85f2b . It does not compile on Windows.
2025-04-01 08:35:51 -07:00
chloe caruso
a199b85f2b
remove many usingnamespace, introduce new ref count and ref leak debugging tools ( #18353 )
2025-03-31 17:17:38 -07:00
Dylan Conway
a3585ff961
node:crypto: implement hkdf and hkdfSync (#18312 )
2025-03-21 01:03:01 -07:00
Ciro Spaciari
ff97424667
fix(SQL) implement unix socket support ( #18196 )
...
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2025-03-15 11:51:20 -07:00
Ciro Spaciari
7f948f9c3e
fix(sql) fix query parameters options ( #18194 )
2025-03-14 13:39:55 -07:00
Dylan Conway
ddfc8555f7
crypto: fix test-crypto-random.js ( #18044 )
...
Co-authored-by: Meghan Denny <meghan@bun.sh >
2025-03-11 18:21:20 -07:00
chloe caruso
1a6a34700f
chore: less usingnamespace, deprecate bun.C in favor of automatic translate-c ( #17830 )
2025-03-03 15:04:21 -08:00
190n
ee6bdc1588
Restore TimerHeap but with behavior matching Node.js ( #17811 )
2025-02-28 19:24:30 -08:00
chloe caruso
4f58ff7933
changes to JSC.Strong, fix memory leaks in dev server ( #17738 )
2025-02-27 15:09:35 -08:00
Jarred Sumner
0237baee92
Zero out sensitive memory before freeing ( #17750 )
2025-02-26 23:34:50 -08:00
190n
b3edef5989
node:timers fixes ( #16855 )
2025-02-26 16:45:02 -08:00
Ciro Spaciari
5c6e20aeb4
fix(sql) fix state being set to prepared too soon ( #17732 )
2025-02-26 16:02:51 -08:00
Meghan Denny
1574df835e
zig: make JSValue.toBunString use JSError ( #17648 )
2025-02-25 13:04:44 -08:00
Ciro Spaciari
09ab840114
fix(sql) fix binary detection + fix custom types ( #17635 )
2025-02-24 20:07:16 -08:00
Meghan Denny
27c90786ca
node: implement process.binding('fs') ( #17480 )
2025-02-20 22:15:01 -08:00
Ciro Spaciari
0efc4eaf97
fix(sql) allow more than 64 columns ( #17444 )
2025-02-18 19:37:26 -08:00
Jarred Sumner
9cf9a26330
Revert "fix(sql) allow more than 64 columns" ( #17441 )
2025-02-18 13:42:59 -08:00
Ciro Spaciari
fcdddf6425
fix(sql) allow more than 64 columns ( #17419 )
2025-02-18 09:07:23 -08:00
Don Isaac
59f3d1ca31
refactor: remove BunString.fromJSRef ( #17367 )
2025-02-15 21:52:13 -08:00