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

Implement placement new concept #224

Closed
elfenpiff opened this issue May 27, 2024 · 3 comments · Fixed by #230
Closed

Implement placement new concept #224

elfenpiff opened this issue May 27, 2024 · 3 comments · Fixed by #230
Assignees

Comments

@elfenpiff
Copy link
Contributor

Brief feature description

See: #220

When a large data type that does not fit into the stack is transmitted via shared memory we encounter a stack overflow. It is caused by a lacking placement new functionality in Rust, see: rust-lang/rust#53827

Example:

let a = Box::new([-1; 3000000]);

We need to add a mechanism so that

let sample = publisher.loan()?;

and

let sample = publisher.loan_uninit()?;
let sample = sample.write_payload(LargeDataType::default());

perform a placement new into the provide shared memory.

Detailed information

One possible solution can be the introduction of a PlacementNew trait in combination with a placement_new derive macro.

@elfenpiff elfenpiff self-assigned this May 27, 2024
@elBoberido
Copy link
Member

There is already a workaround for this available by using

let mut sample = publisher.loan_uninit()?;
let sample = unsafe {
    sample
        .payload_mut()
        .as_mut_ptr()
        .write(LargdDataType::default());

    sample.assume_init()
};

It should work reliably with release builds but might fail with debug builds.

We need a long term solution but I think a build-in Rust solution would be ideal. Maybe this is something we could engage in the Rust community and try to speed it up?

@elfenpiff
Copy link
Contributor Author

@elBoberido, we could try, but I doubt we can realize this in the following months.

I can't entirely agree with calling this reliable when this algorithm depends on a release optimization. For whatever reason, this could be turned off in some corner cases, or the compiler may not be able to realize that it can perform this optimization.

And what if the user, who is using iceoryx, integrates this into unit tests - then it will cause problems again. With this we would also enforce our users to always build in release mode, also during development, which would cause additional problems.

So my take on this is that we require a quick and comfortable solution and we can use our solution as a discussion basis for the Rust community to come to a build-in Rust solution. What do you think?

@elBoberido
Copy link
Member

@elfenpiff I think there are more pressing issues but it's up to you.

elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue May 27, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue May 27, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue May 27, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue May 27, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 1, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 1, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 4, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 4, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 4, 2024
@elfenpiff elfenpiff mentioned this issue Jun 4, 2024
17 tasks
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 4, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 4, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 5, 2024
…w for semantic string since it breaks the contract
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 6, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 6, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 7, 2024
elfenpiff added a commit to elfenpiff/iceoryx2 that referenced this issue Jun 7, 2024
elfenpiff added a commit that referenced this issue Jun 7, 2024
…ew-for-containers

[#224] implement placement new for containers
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 a pull request may close this issue.

2 participants