Skip to content

Commit fda28fa

Browse files
Unsafecell fix (#32)
* Bumped patch release,updated layout for Cell and UnsafeCell due to rustc bug. Link to rust bug rust-lang/rust#68206 * Travis config:remove Cargo.lock after beta builds * Fix previous commit
1 parent 04bde8a commit fda28fa

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ script:
3535
- cd "${TRAVIS_BUILD_DIR}/testing/version_compatibility/impl_0"
3636
- cargo +beta build
3737

38+
- cd "${TRAVIS_BUILD_DIR}/"
39+
- rm Cargo.lock
40+
3841
- cd "${TRAVIS_BUILD_DIR}/examples/0_modules_and_interface_types/impl/"
3942
- cargo check
4043

Changelog.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ This is the changelog,summarising changes in each version(some minor changes may
22

33
# 0.8
44

5+
### 0.8.2
6+
7+
Breaking Change(caused by soundness fix in rustc):
8+
9+
[This unsoundness bug for all Cell-like std types](https://github.com/rust-lang/rust/issues/68206) is going to be solved by making UnsafeCell not propagate niches.
10+
11+
In preparation for this change,this library will not propagate niches from T into `*Cell<T>`,
12+
this will cause runtime errors when loading libraries containing either `*Cell` type wrapping a type with non-zero optimizations (including references,and`NonZero*` types),
13+
and compile-time errors when putting `Option<Cell<NonZero>>` in ffi boundaries.
14+
15+
Dynamic libraries built on a previous patch release might have to be built from scratch,
16+
if they contain the previously mentioned types in their API.
17+
18+
### 0.8.0
19+
520
Added checks when loading dynamic libraries to ensure that Rust doesn't change how it represents
621
zero-sized types in the "C" ABI.
722
This means that in some rare cases,it won't be possible to link dynamic libraries across a

abi_stable/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "abi_stable"
3-
version = "0.8.1"
3+
version = "0.8.2"
44
authors = ["rodrimati1992 <[email protected]>"]
55
edition="2018"
66
license = "MIT/Apache-2.0"

abi_stable/src/abi_stability/stable_abi_trait.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,10 +1188,13 @@ mod rust_1_36_impls{
11881188

11891189
/////////////
11901190

1191-
macro_rules! impl_sabi_for_transparent {
1191+
macro_rules! impl_sabi_for_newtype {
1192+
(@trans transparent)=>{ P::IsNonZeroType };
1193+
(@trans C)=>{ False };
11921194
(
11931195
$type_constr:ident
11941196
$(where[ $($where_clause:tt)* ])* ,
1197+
$transparency:ident,
11951198
$type_name:literal,
11961199
$mod_path:expr
11971200
) => (
@@ -1208,7 +1211,7 @@ macro_rules! impl_sabi_for_transparent {
12081211
$($($where_clause)*)*
12091212
{
12101213
type Kind=ValueKind;
1211-
type IsNonZeroType = P::IsNonZeroType;
1214+
type IsNonZeroType = impl_sabi_for_newtype!(@trans $transparency);
12121215

12131216
const S_LAYOUT: &'static TypeLayout = {
12141217
const MONO_TYPE_LAYOUT:&'static MonoTypeLayout=&MonoTypeLayout::new(
@@ -1243,11 +1246,12 @@ macro_rules! impl_sabi_for_transparent {
12431246
}
12441247

12451248

1246-
impl_sabi_for_transparent!{ Wrapping ,"Wrapping" ,"std::num" }
1247-
impl_sabi_for_transparent!{ Pin ,"Pin" ,"std::pin" }
1248-
impl_sabi_for_transparent!{ ManuallyDrop,"ManuallyDrop","std::mem" }
1249-
impl_sabi_for_transparent!{ Cell ,"Cell" ,"std::cell" }
1250-
impl_sabi_for_transparent!{ UnsafeCell ,"UnsafeCell" ,"std::cell" }
1249+
impl_sabi_for_newtype!{ Wrapping ,transparent,"Wrapping" ,"std::num" }
1250+
impl_sabi_for_newtype!{ Pin ,transparent,"Pin" ,"std::pin" }
1251+
impl_sabi_for_newtype!{ ManuallyDrop,transparent,"ManuallyDrop","std::mem" }
1252+
1253+
impl_sabi_for_newtype!{ Cell ,C,"Cell" ,"std::cell" }
1254+
impl_sabi_for_newtype!{ UnsafeCell ,C,"UnsafeCell" ,"std::cell" }
12511255

12521256
/////////////
12531257

0 commit comments

Comments
 (0)