oven-sh/bun

Segfault when using const value as argument for macro function.

tobilinz opened this issue · 4 comments

What version of Bun is running?

1.0.3

What platform is your computer?

Linux 6.5.3-arch1-1 x86_64 unknown

What steps can reproduce the bug?

  1. Create a new bun project using bun init -y
  2. Paste the following code into index.ts:
import { myMacro } from './other' with { type: 'macro' };
const test = 'Hello World ';
console.log(myMacro(test));
  1. Paste the following code into a new file called other.ts:
export function myMacro(value: string): string {
  return value + "and Bun!";
}
  1. Run bun build ./index.ts

What is the expected behavior?

Console output:

// index.ts
console.log("Hello World and Bun!");

What do you see instead?

Console output:
[1] 27447 segmentation fault (core dumped) bun build ./index.ts

Additional information

This bug also occurs when importing a const from another file or importing the content of a .txt* file and using it as input for a macro function.

  • .wgsl files also cause this behavior. Other file types have not been tested.

I accidentally closed it.

Possibly related: #3832 and #3830 (comment)

Closed by #6756

As mentioned in #3830 the segfault is now correctly handled, however there's still an issue with handling certain values in macros. Not sure this should be closed yet.