Skip to content
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

A few fixes related to CommonJS module loading #9540

Merged
merged 17 commits into from Mar 21, 2024
Merged

Conversation

Jarred-Sumner
Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner commented Mar 21, 2024

What does this PR do?

  • Add extra checks to ensure source code is always freed when it should be
  • Optimization: precompute the hash upfront for source code transpiled on another thread. This seems
  • Make Bun.gc(true) free more memory
  • Make CommonJSModule store the JSC::SourceCode directly instead of using JSC::JSSourceCode. Goal is to free it earlier instead of whenever GC decides to free it.
  • Fixes signal SIGSEGV: invalid address #6946
  • Fixes Crash in module loader when cycles exist between ESM & CJS #8965
  • Fixes a bug where bun loads & transpiles the same code twice(!)

How did you verify your code works?

It doesn't work yet

It crashes in release builds, but not debug builds

I suspect something fishy with either GC or a C++ use-after-move somewhere. Worst case I revert it back

Copy link

github-actions bot commented Mar 21, 2024

❌🪟 @Jarred-Sumner, there are 10 test regressions on Windows x86_64

  • test\cli\hot\hot.test.ts
  • test\cli\install\bun-run-bunfig.test.ts
  • test\cli\install\bunx.test.ts
  • test\cli\install\registry\bun-install-registry.test.ts
  • test\js\bun\console\console-iterator.test.ts
  • test\js\bun\glob\scan.test.ts
  • test\js\bun\shell\commands\rm.test.ts
  • test\js\node\dns\node-dns.test.js
  • test\js\web\fetch\body-stream.test.ts
  • test\js\web\websocket\websocket.test.js

Full Test Output

Copy link

github-actions bot commented Mar 21, 2024

@staabm
Copy link
Contributor

staabm commented Mar 21, 2024

  • Optimization: precompute the hash upfront for source code transpiled on another thread. This seems

nit: it seems the PR description is truncated at this point

Copy link
Collaborator

@paperdave paperdave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good now.

if you are worried about JS code being wrong, feel free to add more $asserts into it (they are tree-shaken)

src/bun.js/module_loader.zig Show resolved Hide resolved
@paperdave paperdave changed the title A few fixes A few fixes related to CommonJS module loading Mar 21, 2024
@Jarred-Sumner Jarred-Sumner merged commit e124f08 into main Mar 21, 2024
1 check passed
@Jarred-Sumner Jarred-Sumner deleted the jarred/further-fixes branch March 21, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash in module loader when cycles exist between ESM & CJS signal SIGSEGV: invalid address
3 participants