Skip to content

fix(ffi): make using tinycc bindings safer - #17397

Merged
paperclover merged 26 commits into
mainfrom
don/chore/tcc
Feb 24, 2025
Merged

paperclover merged 26 commits into
mainfrom
don/chore/tcc

Conversation

@DonIsaac

@DonIsaac DonIsaac commented Feb 17, 2025 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a wrapper to all tcc bindings to convert error codes to error unions, forcing better error handling. FFI errors should be much better handled now, though there is still room for improvement.

This PR also fixes a bus error caused by running library.close() on any library created by cc. Turns out we cannot free relocated memory, even if JIT write protections are disabled.

How did you verify your code works?

I've added tests. These changes should still be carefully reviewed.

@DonIsaac DonIsaac added the bun:ffi Something related with FFI in Bun label Feb 17, 2025
@robobun

robobun commented Feb 17, 2025 •

Copy link
Copy Markdown
Collaborator
Updated 2:13 PM PT - Feb 22nd, 2025

❌ @DonIsaac, your commit c1988a0 has 1 failures in Build #12090:


🧪   try this PR locally:

bunx bun-pr 17397

@DonIsaac DonIsaac added the bun:cc Related to the built-in C compiler label Feb 17, 2025
Comment thread test/js/bun/ffi/cc.test.ts Outdated
Comment thread src/bun.js/api/ffi.zig Outdated
Comment thread src/deps/tcc.zig Outdated
Comment thread test/js/bun/ffi/cc.test.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bun:cc Related to the built-in C compiler bun:ffi Something related with FFI in Bun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants