aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2019-02-16rebase fixJorge Aparicio
2019-02-16cargo fmtJorge Aparicio
2019-02-16make debug builds reproducibleJorge Aparicio
2019-02-16Temporarily disable checking for reproducibility of debug builds.Hugo van der Wijst
2019-02-16Make generated names stable when sorting.Hugo van der Wijst
2019-02-16Seed RNG with package name and prepend string to full random name.Hugo van der Wijst
2019-02-16Fix thumbv6 build.Hugo van der Wijst
2019-02-16Make identifiers deterministic.Hugo van der Wijst
2019-02-16Speed up CI significantly.Hugo van der Wijst
2019-02-16Make builds reproducibleHugo van der Wijst
This is done by using `BTreeMap`s and `BTreeSet`s to get deterministic ordering. Also updated the CI job to check reproducibility of all examples.
2019-02-14fancier redirect pageJorge Aparicio
2019-02-14set a redirect from book/ to book/en/Jorge Aparicio
closes #148
2019-02-14update link to documentation in the READMEJorge Aparicio
2019-02-14update documentation link in crate metadataJorge Aparicio
2019-02-13Merge #145bors[bot]
145: fix non_camel_case_types warnings r=japaric a=japaric closes #144 Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2019-02-13fix non_camel_case_types warningsJorge Aparicio
2019-02-12Merge #142bors[bot]
142: (ru) late resources r=japaric a=burrbull According to 1e9058cab2d29979da9856a8198884b50176ccbc Co-authored-by: Zgarbul Andrey <zgarbul.andrey@gmail.com>
2019-02-12bump macros versionJorge Aparicio
2019-02-12changelog: note that new syntax is documented in the bookJorge Aparicio
2019-02-12(ru) late resourcesZgarbul Andrey
According to 1e9058cab2d29979da9856a8198884b50176ccbc
2019-02-12Merge #140bors[bot]
140: fix soundness issue: forbid early returns in init r=japaric a=japaric TL;DR 1. v0.4.1 will be published once this PR lands 2. v0.4.0 will be yanked once v0.4.1 is out 3. v0.4.1 will reject code that contains early returns in `init` *and* contains late resources. Yes, this is a breaking change but such code is unsound / has undefined behavior. 4. as of v0.4.1 users are encouraged to use `fn init() -> init::LateResources` instead of `fn init()` when they make use of late resources. --- This PR fixes a soundness issue reported by @RalfJung. Basically, early returning from `init` leaves *late resources* (runtime initialized statics) uninitialized, and this produces undefined behavior as tasks rely on those statics being initialized. The example below showcases a program that runs into this soundness issue. ``` rust #[rtfm::app(device = lm3s6965)] const APP: () = { // this is actually `static mut UNINITIALIZED: MaybeUninit<bool> = ..` static mut UNINITIALIZED: bool = (); #[init] fn init() { // early return return; // this is translated into `UNINITIALIZED.set(true)` UNINITIALIZED = true; // the DSL forces you to write this at the end } #[interrupt(resources = [UNINITIALIZED])] fn UART0() { // `resources.UNINITIALIZED` is basically `UNINITIALIZED.get_mut()` if resources.UNINITIALIZED { // undefined behavior } } }; ``` The fix consists of two parts. The first part is producing a compiler error whenever the `app` procedural macro finds a `return` expression in `init`. This covers most cases, except for macros (e.g. `ret!()` expands into `return`) which cannot be instrospected by procedural macros. This fix is technically a breaking change (though unlikely to affect real code out there) but as per our SemVer policy (which follows rust-lang/rust's) we are allowed to make breaking changes to fix soundness bugs. The second part of the fix consists of extending the `init` syntax to let the user return the initial values of late resources in a struct. Namely, `fn() -> init::LateResources` will become a valid signature for `init` (we allowed this signature back in v0.3.x). Thus the problematic code shown above can be rewritten as: ``` rust #[rtfm::app(device = lm3s6965)] const APP: () = { static mut UNINITIALIZED: bool = (); #[init] fn init() -> init::LateResources { // rejected by the compiler // return; //~ ERROR expected `init::LateResources`, found `()` // initialize late resources init::LateResources { UNINITIALIZED: true, } } #[interrupt(resources = [UNINITIALIZED])] fn UART0() { if resources.UNINITIALIZED { // OK } } }; ``` Attempting to early return without giving the initial values for late resources will produce a compiler error. ~~Additionally, we'll emit warnings if the `init: fn()` signature is used to encourage users to switch to the alternative `init: fn() -> init::LateResources` signature.~~ Turns out we can't do this on stable. Bummer. The book and examples have been updated to make use of `init::LateResources`. In the next minor version release we'll reject `fn init()` if late resources are declared. `fn init() -> init::LateResources` will become the only way to initialize late resources. This PR also prepares release v0.4.1. Once that version is published the unsound version v0.4.0 will be yanked. Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2019-02-12update CHANGELOG with alt init syntaxJorge Aparicio
2019-02-12(en) update the text related to late resourcesJorge Aparicio
cc @burrbull
2019-02-12update examples and testsJorge Aparicio
2019-02-12accept `init: fn() -> init::LateResources`Jorge Aparicio
2019-02-12v0.4.1Jorge Aparicio
2019-02-12document MSRV and SemVer policyJorge Aparicio
2019-02-12forbid early returns in initJorge Aparicio
2019-02-12(ru) fix includes in the prefaceJorge Aparicio
2019-02-11fix ci/after-success.shJorge Aparicio
2019-02-11Merge #139bors[bot]
139: russian translation r=japaric a=japaric Co-authored-by: Jorge Aparicio <jorge@japaric.io> Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2019-02-11change layout of booksJorge Aparicio
2019-02-10(ru) not a betaAndrey Zgarbul
2019-02-09(ru) changes according reviewAndrey Zgarbul
2019-02-08russian translationAndrey Zgarbul
2019-02-08skeleton for the Russian translation of the bookJorge Aparicio
2019-02-08Merge #137bors[bot]
137: impl Default for Duration r=japaric a=japaric closes #134 Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2019-02-08impl Default for DurationJorge Aparicio
2019-01-22Merge #133bors[bot]
133: Fix build on recent nightlies. r=japaric a=hugwijst Co-authored-by: Hugo van der Wijst <hvanderwijst@tesla.com>
2019-01-17Fix build on recent nightlies.Hugo van der Wijst
2019-01-09Merge pull request #125 from eddyp/masterJorge Aparicio
Absolute link to the book so it works on crates.io
2019-01-09Absolute link to the book so it works on crates.ioEddy Petrișor
Signed-off-by: Eddy Petrișor <eddy.petrisor@gmail.com>
2019-01-03Merge pull request #120 from kraai/patch-2Jorge Aparicio
Fix grammar
2018-12-21Fix grammarMatt Kraai
2018-12-21Merge pull request #119 from kraai/patch-1Jorge Aparicio
Fix misspelling of "capacity"
2018-12-21Fix misspelling of "capacity"Matt Kraai
2018-12-19Merge #118bors[bot]
118: a few doc tweaks r=japaric a=japaric Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2018-12-17note that entering / leaving a critical section is always constant timeJorge Aparicio
2018-12-17make docs.rs build docs with +timer-queueJorge Aparicio
2018-12-16Merge #116bors[bot]
116: v0.4.0 r=japaric a=japaric Co-authored-by: Jorge Aparicio <jorge@japaric.io>