Skip to content

Expands the API and reroutes all allocation through GlobalCtx #10

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

Merged
merged 24 commits into from
Apr 3, 2025

Conversation

icmccorm
Copy link
Collaborator

@icmccorm icmccorm commented Mar 27, 2025

This is the second part of the change mentioned in #4. It's dependent on #9

New Types

  • Adds Span as a wrapper for usize
  • Adds AllocId as wrapper for usize
  • Adds BorTag as a wrapper for usize
  • Adds AllocInfo, a metadata object for each allocation. Contains the ID, base, bounds, size, alignment, and Tree for an allocation. The tree is currently a pointer to c_void, as we haven't yet added the state of the borrow tracker.
  • Adds Provenance, which contains an AllocID, a BorTag, and a pointer to AllocInfo.
  • Renames GlobalState to GlobalCtx
  • Renames BsanAllocator to BsanHooks
  • Factors out BsanAllocHook from BsanHooks to use for an Allocator implementation that's also Copy

Expanded Global State

  • Adds hooks for printing (Print) and terminating (Exit).
  • Adds custom print! and println! macros that use GlobalCtx
  • Adds ui_test! macro, which will print only if the ui_test feature is enabled.
  • Adds Hello, world! UI test which verifies that we've initialized our runtime.
  • Adds BVec, BHashMap, and BVecDeque wrappers that enforce use of the GlobalCtx as an allocator.

Additional API Functions

  • Switches to using return pointers for Provenance values
  • Adds bsan_deinit endpoint that deinitializes the state of the runtime. Called automatically on termination.
  • Adds endpoints for setting and clearing provenance from the shadow heap. (bsan_shadow_copy, bsan_shadow_clear)
  • Adds endpoints for popping and pushing stack frames (bsan_push_frame, bsan_pop_frame)
  • Adds endpoints for allocation (bsan_alloc, bsan_dealloc, and bsan_alloc_stack)
  • Adds endpoints for storing and loading provenance values from the shadow heap (bsan_store_prov, bsan_load_prov)

@icmccorm icmccorm force-pushed the bsan-stabilize-interface branch from 3d60e23 to 503d0b9 Compare March 28, 2025 16:46
@icmccorm icmccorm changed the title Expand the API and reroute all allocation through GlobalCtx Expands the API and reroutes all allocation through GlobalCtx Mar 30, 2025
@icmccorm icmccorm requested a review from obraunsdorf March 30, 2025 01:48
@icmccorm
Copy link
Collaborator Author

icmccorm commented Apr 1, 2025

ARM linux is disabled in CI due to #6

@obraunsdorf obraunsdorf merged commit 5c93db1 into bsan Apr 3, 2025
3 checks passed
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.

2 participants