Meghan Denny
45760cd53c
ci: instrument being able to run leaksanitizer ( #21142 )
...
tests not in `test/no-validate-leaksan.txt` will run with leaksanitizer
in CI
leaks documented in `test/leaksan.supp` will not cause a test failure
-- notes about leaksanitizer
- will not catch garbage collected objects accumulated during
long-running processes
- will not catch js objects (eg a strong held to a promise)
- will catch native calls to `malloc` not `free`d
- will catch allocations made in C, Zig, C++, libc, dependencies,
dlopen'd
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2025-09-19 02:06:02 -07:00
robobun
7110dc10a4
Fix UTF-16 encoding crash with odd-length byte arrays ( #21966 )
...
## Summary
- Fixes a panic: "exact division produced remainder" that occurs when
reading files with odd number of bytes using utf16le/ucs2 encoding
- The crash happened in `encoding.zig:136` when
`std.mem.bytesAsSlice(u16, input)` was called on a byte slice with odd
length
- Fixed by properly checking for odd-length input and truncating to the
nearest even length
## Test plan
- Added regression tests in
`test/regression/issue/utf16-encoding-crash.test.ts`
- Tests verify that reading files with odd byte counts doesn't crash
- Tests verify correct truncation behavior matches Node.js expectations
- Verified edge cases (0, 1 byte inputs) return empty strings
## Root Cause
The original code checked `if (input.len / 2 == 0)` which only caught 0
and 1-byte inputs, but `std.mem.bytesAsSlice(u16, input)` panics on any
odd-length input (3, 5, 7, etc. bytes).
## Fix Details
- Changed condition to check `input.len % 2 != 0` for any odd length
- Truncate odd-length inputs to the nearest even length for valid UTF-16
processing
- Handle edge cases by returning empty string for 0 or 1-byte inputs
🤖 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: Jarred Sumner <jarred@jarredsumner.com >
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com >
2025-08-20 00:02:14 -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
Zack Radisic
ac61b1d471
Use better function names for bun.String ( #20999 )
2025-07-12 18:19:16 -07:00
Zack Radisic
61024b2b4a
Fix copying UTF-16 -> UTF-8 sometimes causing invalid UTF-8 bytes ( #20601 )
2025-06-24 19:46:29 -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
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
Jarred Sumner
0471254e4e
Use Highway SIMD ( #19134 )
...
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com >
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com >
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com >
2025-04-21 23:28:03 -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
50eaea19cb
Move TextDecoder, TextEncoderStreamEncoder, TextEncoder, EncodingLabel into separate files ( #18430 )
2025-03-24 17:10:48 -07:00
190n
cde668b54c
Better edge case handling in napi_value<->String conversion ( #18107 )
2025-03-12 18:15:00 -07:00
Kai Tamkun
4a0e982bb2
node:http improvements ( #17093 )
...
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
Co-authored-by: Pham Minh Triet <92496972+Nanome203@users.noreply.github.com >
Co-authored-by: snwy <snwy@snwy.me >
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com >
Co-authored-by: cirospaciari <cirospaciari@users.noreply.github.com >
Co-authored-by: Ben Grant <ben@bun.sh >
2025-03-10 20:19:29 -07:00
Meghan Denny
d862966631
node: test-buffer-write.js ( #17450 )
2025-02-22 00:24:44 -08:00
Meghan Denny
04703bd3cc
zig: catch JSValue.toZigString/getZigString thrown exceptions ( #17508 )
2025-02-21 22:55:03 -08:00
Meghan Denny
26d3688e53
zig: update to 0.14.0-dev ( #16862 )
...
Co-authored-by: nektro <5464072+nektro@users.noreply.github.com >
2025-02-01 01:11:02 -08:00
Meghan Denny
676e8d1632
zig: delete is_bindgen ( #16858 )
2025-01-28 23:51:24 -08:00
Jarred Sumner
843cb38d3b
Fix memory leak in pathToFileURL ( #16784 )
2025-01-26 22:35:45 -08:00
Ciro Spaciari
23b64f782b
toSliced2 becomes toSlice to make sure that exceptions are handled properly ( #16734 )
2025-01-24 23:27:08 -08:00
Jarred Sumner
ccb094b7a8
Fix under-reporting memory usage for strings ( #16737 )
2025-01-24 20:45:34 -08:00
chloe caruso
5819fe49a7
node fs compat pr #2 ( #16422 )
...
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com >
Co-authored-by: Meghan Denny <meghan@bun.sh >
Co-authored-by: dylan-conway <35280289+dylan-conway@users.noreply.github.com >
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2025-01-21 10:28:35 -08:00
Meghan Denny
2d441d868b
zig: make throw use JSError ( #15444 )
2024-12-02 14:19:18 -08:00
Meghan Denny
663f00b62b
zig: make throwOutOfMemory use JSError ( #15413 )
2024-11-26 12:58:43 -08:00
Meghan Denny
c3f63bcdc4
zig: make throwInvalidArguments use JSError ( #15305 )
2024-11-21 16:19:13 -08:00
Meghan Denny
0e3e33072b
zig: rename CallFrame.arguments to .arguments_old to free up decl name ( #15296 )
2024-11-20 16:18:56 -08:00
Meghan Denny
1efab7f42d
zig: JSValue: make .get and .toSliceOrNull use JSError ( #15270 )
2024-11-20 13:26:41 -08:00
Meghan Denny
ab3cb68f66
zig: make throwNotEnoughArguments use JSError ( #15266 )
2024-11-19 19:07:14 -08:00
Meghan Denny
2810f39802
zig: make all JS constructors use JSError ( #15146 )
...
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com >
2024-11-14 16:36:01 -08:00
Meghan Denny
fdd8d35845
allow zig js host functions to return JSError ( #15120 )
2024-11-13 21:11:56 -08:00
Meghan Denny
35513a9d6d
zig: remove JSValue.isEmpty ( #15128 )
2024-11-13 16:04:13 -08:00
Meghan Denny
f8979b05b1
rid nearly all use of ExceptionRef in zig ( #15100 )
...
Co-authored-by: nektro <nektro@users.noreply.github.com >
2024-11-13 15:23:52 -08:00
Jarred Sumner
781a392baa
Add micro-optimization to fs.readFile ( #15076 )
2024-11-11 10:35:17 -08:00
Dylan Conway
66ba6ba061
fix 14957 ( #15025 )
2024-11-06 19:41:39 -08:00
Jarred Sumner
b1e9e3b31b
Add bytesWritten property to Bun.Socket, fix encoding issue in node:net ( #14516 )
...
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com >
2024-10-31 17:54:07 -07:00
dave caruso
514d37b3d2
kit: implement server components dev server ( #14025 )
2024-09-27 20:53:39 -07:00
Dylan Conway
5bd344281f
fix(TextEncoder): domjit crash in encode ( #13320 )
...
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2024-08-15 03:35:58 -07:00
Jarred Sumner
d861347dc5
Optimize TextEncoderStream, part 1 ( #13222 )
2024-08-10 02:13:36 -07:00
Dylan Conway
9302b42919
revert 84c91bf7e1 ( #13214 )
2024-08-09 19:28:08 -07:00
Jarred Sumner
7aaf935711
Handle OOM better ( #13142 )
2024-08-09 00:43:54 -07:00
Ashcon Partovi
84c91bf7e1
Revert TextDecoderStream until next release ( #13151 )
2024-08-07 12:34:04 -07:00
Dylan Conway
9f7c6e34cb
Add TextDecoderStream, TextEncoderStream, and TextDecoder.decode("", { stream: true}) ( #13115 )
2024-08-07 02:36:29 -07:00
Jarred Sumner
cacbaba524
Make signal.abort() from native code fast ( #13064 )
2024-08-05 15:50:36 -07:00
Dylan Conway
6303af3ce0
fix(TextDecoder): decoding sequences starting with 192 or 193 ( #13043 )
2024-08-02 23:01:34 -07:00
Meghan Denny
f7cb2da542
use .undefined literal instead of jsUndefined() call ( #12834 )
2024-07-26 04:03:55 -07:00
Jarred Sumner
b0018465cc
WebKit upgrade ( #12246 )
...
Co-authored-by: Jarred-Sumner <Jarred-Sumner@users.noreply.github.com >
2024-07-01 23:27:59 -07:00
Jarred Sumner
7f3e6f23f6
Refactor ZigString -> toJS ( #12242 )
2024-06-29 00:21:42 -07:00
Jarred Sumner
a0032d1b5c
Replace libbase64 with simdutf ( #11982 )
2024-06-19 23:02:56 -07:00
Jarred Sumner
688844b472
refactor: ban std.debug.assert ( #10168 )
...
* Ban `std.debug.assert`
* Create .clangd
* Update lint.yml
* Update linter.ts
* update
* lint
* Update linter.ts
* Update linter.ts
* update
* Update linter.ts
* update
* Update linter.ts
* more
* Update install.zig
* words
* Remove UB
2024-04-11 17:52:29 -07:00
Meghan Denny
e209ae81dd
meta: ensure there's a single 'bun' import per file in zig ( #10137 )
...
* meta: ensure there's a single 'bun' import per file in zig
* undo this change in codegen
2024-04-09 22:41:07 -07:00