Ensured labels are not mistaken for comments by skipping comment
filtering when the line matches a label definition
Added a regression test verifying that labels starting with “@” remain
visible even when comment filtering is enabled
Fixes#7889
Tested with
npm run lint
npm run ts-check
npm run test-min
npm run check-frontend-imports
make check
## Summary
- Fixes EBADF error in HeaptrackWrapper by removing redundant file
descriptor close operation
- The net.Socket takes ownership of the FD and closes it during cleanup,
making manual close unnecessary and dangerous
## Root Cause Analysis
The issue occurred in `lib/runtime-tools/heaptrack-wrapper.ts:133` where
the code attempted to manually close a file descriptor that was already
owned by a `net.Socket`. When creating a socket with `new
net.Socket({fd: fd})`, the socket takes ownership of the file descriptor
and closes it during cleanup operations like `resetAndDestroy()`.
Attempting to close the FD again results in:
1. EBADF errors when the FD hasn't been recycled
2. Potentially closing a different resource if the FD has been recycled
by the OS
## Solution
Removed the manual `oldfs.close(fd)` call since the socket handles FD
cleanup automatically. This prevents both the EBADF error and the more
dangerous scenario of closing recycled file descriptors.
## Verification
Created tests to verify that `net.Socket` takes ownership of file
descriptors:
```javascript
// Test confirms that after socket.destroy(), the FD is no longer valid
const fd = fs.openSync(pipePath, O_RDWR | O_NONBLOCK);
const socket = new net.Socket({ fd: fd, readable: true, writable: true });
socket.destroy();
// fs.fstatSync(fd) throws EBADF - confirming FD was closed by socket
```
## Test Plan
- [x] TypeScript compilation passes
- [x] Minimal test suite passes
- [x] Pre-commit hooks pass
- [x] Created unit test to verify net.Socket FD ownership behavior
Fixes COMPILER-EXPLORER-EA7
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
- Removes `rootDirs` so all imports will be relative in the frontend
- Updates (and unifies) imports to be `../types/...` etc instead of
relying on "types" being in the rootDir for the frontend.
- Fixes one type that was being picked up from `lib` in the frontend.
- Adds a precommit hook to check in future
Paves the way to writing _unit_ tests for the frontend for the subset of
the frontend code we can import from `node` (which might be a lot of
it!)
<!-- THIS COMMENT IS INVISIBLE IN THE FINAL PR, BUT FEEL FREE TO REMOVE
IT
Thanks for taking the time to improve CE. We really appreciate it.
Before opening the PR, please make sure that the tests & linter pass
their checks,
by running `make check`.
In the best case scenario, you are also adding tests to back up your
changes,
but don't sweat it if you don't. We can discuss them at a later date.
Feel free to append your name to the CONTRIBUTORS.md file
Thanks again, we really appreciate this!
-->
Co-authored-by: Ofek Shilon <oshilon@speedata.io>
Fix#7809 and then some:
Stop processing opt-remarks if none were requested,
Make gcc dump remarks to file,
separate opt-file handling to ClangCompiler and GccCompiler,
make DefaultCompiler inherit GccCompiler,
move some tests around.
Resolves#7780.
Basically a follow-up to #7652; the output format of `rustc --help` was
changed to include angle brackets `<` and `>`. This PR updates the
regexes used to parse the help output and adds some tests.
## Summary
- Extracted source line handling logic into a dedicated
`SourceLineHandler` class that consolidates .loc, .stabs, and .6502
directive parsing
- Extracted label processing logic into a `LabelProcessor` class with
methods for finding used labels and filtering
- Created a `ParsingState` class to manage parsing loop state variables
in a centralized way
- Fully integrated all components into the main `AsmParser` class,
replacing the original complex parsing loop
## Changes Made
- **SourceLineHandler**: Unifies `.loc`, `.d2line`, `.cv_loc`, `.dbg`,
`.stabn`, and 6502 debug directive parsing
- **LabelProcessor**: Handles complex label detection, filtering, and
cleanup logic with MIPS/non-MIPS support
- **ParsingState**: Encapsulates state management during parsing
(inNvccCode, inCustomAssembly, etc.)
- **Integration**: All components work together through well-defined
interfaces
## Verification
- ✅ All 1082+ tests pass, including new subclass compatibility tests
from PR #7779
- ✅ All 670+ filter tests pass, confirming exact behavior preservation
- ✅ Added comprehensive unit tests for all new components (32 tests
total)
- ✅ TypeScript compilation and linting pass
- ✅ No performance regression in core functionality
## Bug Fix Discovered
The refactoring inadvertently **fixes issue #7781** - EWAVR label
detection bug:
- **Before**: EWAVR couldn't find labels in usage contexts like `ldi
r16, HIGH(_data)` due to `labelFindFor()` returning definition regex
- **After**: Now correctly uses `identifierFindRe` to find labels in
usage contexts
- Updated tests to reflect the corrected behavior
## Benefits
- Reduced complexity in the main `processAsm` method (from 180+ lines to
more manageable chunks)
- Extracted highly testable, focused components with single
responsibilities
- Eliminated code duplication between source handling methods
- Centralized state management reduces scattered variable handling
- Maintained full backward compatibility and exact behavior
- Fixed EWAVR label detection bug as a side effect
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
## Summary
Fixes unsafe type casting in assembly processing tools that was causing
`TypeError: text.split is not a function` runtime crashes.
## Root Cause Analysis
**COMPILER-EXPLORER-C2N** (57 occurrences) and **COMPILER-EXPLORER-AWW**
(184 occurrences):
The issue stemmed from tools making unsafe assumptions about
`compilationInfo.asm` type:
```typescript
// CompilationInfo.asm type (from types/compilation/compilation.interfaces.ts:168)
asm?: ParsedAsmResultLine[] | string; // "Temp hack until we get all code to agree on type of asm"
```
**The bug sequence:**
1. `base-compiler.ts:3120` converts string assembly to parsed format:
`result.asm = [{text: result.asm}]`
2. Tools unsafely cast back to string: `compilationInfo.asm as string`
3. `AsmParser.processBinaryAsm()` calls `splitLines(asmResult)`
4. If `asm` is actually `ParsedAsmResultLine[]`, `splitLines()` receives
an array
5. `text.split()` fails because arrays don't have `.split()` method
**Affected tools:** osaca-tool, x86to6502-tool, llvm-mca-tool
## Changes
### New Helper Functions in `utils.ts`:
1. **`extractTextLines(asm: string | any[]): string[]`**
- Safely extracts text lines from union types
- Throws descriptive errors for unexpected types (will surface in
Sentry)
2. **`normalizeAsmToString(asm: string | any[] | undefined): string`**
- Centralizes the common pattern of converting union type to string for
parser consumption
- Handles undefined gracefully
### Tool Fixes:
- **Removed unsafe casts**: `compilationInfo.asm as string` →
`normalizeAsmToString(compilationInfo.asm)`
- **Added null checks**: Explicit error handling for missing assembly
data
- **Type safety**: No more runtime type assumptions
## Impact
- Eliminates root cause of `text.split is not a function` errors (241+
occurrences combined)
- Maintains existing functionality - tools continue to work normally
- Better error messages when assembly data is missing
- Centralizes type handling logic for future maintainability
**Note:** The underlying architectural issue (union type "temp hack")
remains, but tools now handle it safely without crashes.
Fixes COMPILER-EXPLORER-C2N
Fixes COMPILER-EXPLORER-AWW
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mats Jun Larsen <mats@jun.codes>
## Summary
- Fixes COMPILER-EXPLORER-E53: SyntaxError: Unexpected end of JSON input
- Adds robust error handling for malformed client state URLs
- Prevents Sentry notifications for user-caused errors
## Root Cause
The `extractJsonFromBufferAndInflateIfRequired` function and
`unstoredStateHandler` were not properly handling:
- Invalid base64 data in URLs
- Corrupted or malformed JSON after base64 decoding
- Empty JSON strings
This caused uncaught `SyntaxError` exceptions that were being sent to
Sentry as internal server errors.
## Changes
- Added proper error handling for base64 decoding failures
- Added validation for empty JSON strings before parsing
- Changed logging from `warn` to `debug` since this represents user
error
- Removed Sentry capture for malformed URLs to reduce noise
- Return 400 Bad Request instead of 500 Internal Server Error
## Test Plan
- [x] TypeScript compilation passes
- [x] All existing tests pass
- [x] Manual testing with malformed URLs returns 400 instead of 500
- [x] No Sentry errors generated for user-caused malformed URLs
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
## Summary
- Fixes syntax highlighting issue where Rust hex literals with
underscores after hex letters (like `0x01_02_0a_0b`) would lose
highlighting after the underscore
- Created custom Rust language mode (`rustp`) that patches Monaco's
built-in tokenizer
- Filed upstream issue with Monaco Editor:
https://github.com/microsoft/monaco-editor/issues/4917
## Test plan
- [x] Verified fix works locally with test cases like `0x01_02_0a_0b`,
`0xFF_AA_BB_CC`, etc.
- [x] Confirmed all existing tests pass
- [x] Checked that TypeScript compilation and linting pass
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
This PR fixes the LLVM IR output for the Mojo compiler integration,
ensuring the LLVM IR panel works correctly and no longer shows "Internal
error; unable to open output path" errors.