robobun
edea077947
Fix env_loader allocator threading issue with BUN_INSPECT_CONNECT_TO ( #22206 )
...
## Summary
- Fixed allocator threading violation when `BUN_INSPECT_CONNECT_TO` is
set
- Created thread-local `env_loader` with proper allocator isolation in
debugger thread
- Added regression test to verify the fix works correctly
## Problem
When `BUN_INSPECT_CONNECT_TO` environment variable is set, Bun creates a
debugger thread that spawns its own `VirtualMachine` instance.
Previously, this VM would fall back to the global `DotEnv.instance`
which was created with the main thread's allocator, causing threading
violations when the debugger thread accessed environment files via
`--env-file` or other env loading operations.
## Solution
Modified `startJSDebuggerThread` in `src/bun.js/Debugger.zig` to:
1. Create a thread-local `DotEnv.Map` and `DotEnv.Loader` using the
debugger thread's allocator
2. Pass this thread-local `env_loader` to `VirtualMachine.init()` to
ensure proper allocator isolation
3. Prevent sharing of allocators across threads
## Test plan
- [x] Added regression test in
`test/regression/issue/test_env_loader_threading.test.ts`
- [x] Verified basic Bun functionality still works
- [x] Test passes with both normal execution and with
`BUN_INSPECT_CONNECT_TO` set
🤖 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>
2025-08-28 17:16:37 -07:00
..
2025-08-26 12:50:25 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-08-11 20:19:34 -07:00
2025-08-26 12:50:25 -07:00
2025-07-22 17:51:38 -07:00
2025-08-28 17:16:37 -07:00
2025-08-26 19:45:57 -07:00
2025-08-27 06:39:11 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-08-11 20:19:34 -07:00
2025-08-26 12:50:25 -07:00
2025-07-17 03:13:48 -07:00
2025-08-26 12:50:25 -07:00
2025-08-24 14:06:39 -07:00
2025-08-26 12:50:25 -07:00
2025-08-28 15:05:52 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-07-31 22:07:17 -07:00
2025-08-11 20:19:34 -07:00
2025-08-28 04:24:04 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-08-22 23:04:58 -07:00
2025-07-23 17:10:58 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 17:58:08 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-07-21 13:26:47 -07:00
2025-08-11 13:40:07 -07:00
2025-08-26 12:50:25 -07:00
2025-06-04 19:41:26 -07:00
2025-08-11 20:19:34 -07:00
2024-10-08 23:04:05 -07:00
2025-08-26 12:50:25 -07:00
2025-08-23 06:55:30 -07:00
2025-05-14 18:42:42 -07:00
2025-07-29 19:35:46 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-04-17 14:17:08 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-07-20 23:04:17 -07:00
2025-08-23 06:57:00 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-06-12 14:20:28 -07:00
2025-08-11 20:19:34 -07:00
2025-07-21 13:26:47 -07:00
2025-08-27 15:31:28 -07:00
2025-07-22 17:51:38 -07:00
2025-08-20 01:25:49 -07:00
2025-07-31 00:56:50 -07:00
2025-08-11 20:19:34 -07:00
2025-08-21 18:52:17 -07:00
2025-07-22 17:51:38 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-08-07 15:16:44 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-07-28 00:13:17 -07:00
2025-08-22 23:04:58 -07:00
2025-05-08 23:22:16 -07:00
2025-05-08 23:22:16 -07:00
2024-09-03 21:32:52 -07:00
2022-07-09 00:57:08 -07:00
2025-08-14 18:03:26 -07:00
2025-08-27 06:39:11 -07:00
2025-05-08 23:22:16 -07:00
2024-12-10 12:43:17 -08:00
2025-08-21 15:28:15 -07:00
2025-08-26 12:50:25 -07:00
2025-08-23 06:55:30 -07:00
2025-06-03 23:51:03 -07:00
2025-08-01 23:38:34 -07:00
2025-08-26 12:50:25 -07:00
2025-08-15 19:05:25 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-07-09 00:19:57 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-08-23 06:55:30 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-08-25 17:37:12 -07:00
2025-08-26 12:50:25 -07:00
2024-12-10 12:43:17 -08:00
2025-07-21 13:26:47 -07:00
2025-03-26 23:57:10 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-08-14 21:12:22 -07:00
2025-02-18 10:38:37 -08:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-07-22 17:51:38 -07:00
2025-08-22 23:04:58 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-08-18 20:02:08 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-08-22 23:04:58 -07:00
2025-07-22 17:51:38 -07:00
2024-01-19 17:30:57 -08:00
2025-08-26 12:50:25 -07:00
2025-06-22 20:51:45 -07:00
2025-07-22 17:51:38 -07:00
2025-08-11 13:40:07 -07:00
2025-02-02 00:20:45 -08:00
2025-07-21 13:26:47 -07:00
2025-08-26 12:50:25 -07:00
2025-07-21 13:26:47 -07:00
2025-08-26 12:50:25 -07:00
2025-07-13 04:27:43 -07:00
2025-07-13 04:27:43 -07:00
2025-07-13 04:27:43 -07:00
2025-07-25 12:38:06 -07:00
2025-08-14 18:03:26 -07:00
2025-07-21 13:26:47 -07:00
2025-08-04 19:21:28 -07:00
2025-07-25 12:38:06 -07:00
2025-07-21 13:26:47 -07:00
2025-02-01 01:11:02 -08:00
2025-08-26 12:50:25 -07:00
2025-05-08 23:22:16 -07:00
2025-07-21 13:26:47 -07:00
2025-08-11 20:19:34 -07:00
2025-07-21 13:26:47 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-07-22 17:51:38 -07:00
2025-08-11 20:19:34 -07:00
2025-07-20 23:04:17 -07:00
2025-08-23 06:55:30 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00