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

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

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open

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

wants to merge 26 commits into from

Conversation

DonIsaac
Copy link
Contributor

@DonIsaac DonIsaac commented Feb 17, 2025

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
Copy link

robobun commented Feb 17, 2025

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
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.

4 participants