Skip to content

Provide Rust wrapper for memory resouces - #406

Open
eclipse-impl wants to merge 4 commits into
eclipse-score:mainfrom
eclipse-impl:swp-271166
Open

Provide Rust wrapper for memory resouces#406
eclipse-impl wants to merge 4 commits into
eclipse-score:mainfrom
eclipse-impl:swp-271166

Conversation

@eclipse-impl

Copy link
Copy Markdown
Contributor

This allows Rust applications that interface with C++ to obtain memory resources to pass back to C++, such that the C++ code will allocate from them, allowing for controlling the memory allocation between the languages.

@github-actions

Copy link
Copy Markdown

The created documentation from the pull request is available at: docu-html

Using cc_common_link tells Bazel that it should drive the linking process instead of Rust.
Therefore, the necessary configuration for ASan is present, whereas Rustc wouldn't know it.
The mangled symbols flag is needed because Rustc mangles the symbols when compiling, and
Bazel expects no mangled symbols by default.
ASan is now properly configured for Rust, and detected a memory leak on `JoinInner::join()`.
The code was using `core::mem::forget(self)` to avoid its own `drop()` from joining the thread again.
However, `self` contains a `Arc<Packet<T>>` that would then remain with reference count 1,
meaning that it would never be freed (memory leak).

The fix uses `core::ptr::read` to copy the bytes to a local variable (`packet`),
that effectively assumes the Packet's ownership. Thus, when `join()` ends, `packet` goes out-of-scope,
and the reference count drops to 0, cleaning up the underlying Packet.
Solves the linking problem on atomic symbols.
@eclipse-impl
eclipse-impl temporarily deployed to workflow-approval July 29, 2026 09:17 — with GitHub Actions Inactive
@eclipse-impl
eclipse-impl temporarily deployed to workflow-approval July 29, 2026 09:17 — with GitHub Actions Inactive
@pawelrutkaq

Copy link
Copy Markdown
Contributor

@arkjedrz have a look please

@eclipse-impl
eclipse-impl marked this pull request as ready for review July 30, 2026 09:29

@arkjedrz arkjedrz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks okay code-wise. It'll be necessary to introduce directives to AI agents on how to write comments and docs though.

Just for now You can ask Your AI agent to rewrite them in following way:

  • Make docs concise and information-bearing.
  • Avoid filler, pleasantries, and hedging.
  • Write one sentence per line.
  • Do not decorate sections (e.g. with long ---------- comments).
  • Do not wrap a sentence across lines, first try to rephrase it to fit.
  • Wrap only when unavoidable. Use formatter column limit for comments. Do not wrap Markdown - rephrase or keep as is.
  • Double spaces between sentences are unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants