New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Macro crashes with SIGSEGV when non-ASCII character in string template literal with interpolation #3641
Comments
Interesting, this code is supposed to panic instead of segfault. https://github.com/oven-sh/bun/blob/main/src/js_ast.zig#L10026-L10028 |
I've only seen that condition trigger when trying to use a macro as a tagged template literal function, like so: import { fn } from './macro' assert { type: 'macro' };
fn`...`; |
Using the macro in a test sheds some light on why it's seg faulting. There is an extra character being prepended to Unicode characters outside the ASCII range. Try:
import { test, expect } from 'bun:test';
import { fn } from './macro' assert { type: 'macro' };
test('fails', () => {
expect(fn('©')).toBe('©');
});
Result:
So it's likely something to do with string handling in macro arguments and probably not template literals specifically since the test uses a regular string. |
Continued in: #3830 |
What version of Bun is running?
0.6.14
What platform is your computer?
Linux 6.4.3-arch1-1 x86_64 unknown
What steps can reproduce the bug?
index.ts
:macro.ts
:bun build ./index.ts
orbun ./index.ts
.What is the expected behavior?
Template literals are processed correctly as Unicode when passed as macro arguments.
Bun process runs without a segmentation fault.
What do you see instead?
Additional information
When there is no interpolation in the template literal the macro works as expected, even when it contains non-ASCII characters.
Where there are only ASCII characters, interpolation in the template literal the macro works as expected.
Happens on both stable
v0.6.14 (b5665739)
and current canaryv0.6.15 (c39c11e1)
.The text was updated successfully, but these errors were encountered: