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

Replaced *mut T by Option<NonNull<T>> in box.rs #1

Merged
merged 2 commits into from
Jun 24, 2019
Merged

Replaced *mut T by Option<NonNull<T>> in box.rs #1

merged 2 commits into from
Jun 24, 2019

Conversation

danielhenrymantilla
Copy link
Contributor

No description provided.

@kvark
Copy link
Owner

kvark commented Mar 25, 2019

@danielhenrymantilla thank you for the PR!
It looks good to me. Wondering why you didn't go further as suggested in #2 (comment) ?

@danielhenrymantilla
Copy link
Contributor Author

Since you were nowhere to be seen I was on standby ^^'

There it is

src/boxed.rs Outdated
})
BoxAllocation(
ptr::NonNull::new(unsafe { alloc::alloc(layout) as *mut T })
.unwrap_or_else(|| std::process::abort()) // abort on oom
Copy link
Owner

Choose a reason for hiding this comment

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

how is this different from just unwrap()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, for a long time Rust strtegy on oom was to abort (since a panic! unwinds the stack, running destructors, which may allocate memory), but now that you point it out, more "recent" threads such as rust-lang/rust#43596 seem to point in the opposite direction. I will investigate further to see if replacing it with .unwrap() is now the preferred approach.

@eun-ice eun-ice mentioned this pull request Mar 26, 2019
@novacrazy
Copy link

What’s the status on this?

Copy link
Owner

@kvark kvark left a comment

Choose a reason for hiding this comment

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

It's a good change, just needs a rebase

@kvark
Copy link
Owner

kvark commented Jun 24, 2019

bors r+

bors bot added a commit that referenced this pull request Jun 24, 2019
1: Replaced *mut T by Option<NonNull<T>> in box.rs r=kvark a=danielhenrymantilla



Co-authored-by: danielhenrymantilla <daniel.henry.mantilla@gmail.com>
@bors
Copy link
Contributor

bors bot commented Jun 24, 2019

Build succeeded

@bors bors bot merged commit 5872f04 into kvark:master Jun 24, 2019
@kvark
Copy link
Owner

kvark commented Jul 4, 2019

@danielhenrymantilla we just realized that this PR fixed an UB behavior on alloc() returning NULL.
So good thing this is now merged and published. We need to update the use of copyless by library clients to 0.1.4

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.

None yet

3 participants