1. 16 5月, 2021 5 次提交
    • H
      More tests for issue-85255 · 2cb1ba36
      hi-rustin 提交于
      2cb1ba36
    • B
      Auto merge of #81858 - ijackson:fork-no-unwind, r=m-ou-se · d565c748
      bors 提交于
      Do not allocate or unwind after fork
      
      ### Objective scenarios
      
       * Make (simple) panics safe in `Command::pre_exec_hook`, including most `panic!` calls, `Option::unwrap`, and array bounds check failures.
       * Make it possible to `libc::fork` and then safely panic in the child (needed for the above, but this requirement means exposing the new raw hook API which the `Command` implementation needs).
       * In singlethreaded programs, where panic in `pre_exec_hook` is already memory-safe, prevent the double-unwinding malfunction #79740.
      
      I think we want to make panic after fork safe even though the post-fork child environment is only experienced by users of `unsafe`, beause the subset of Rust in which any panic is UB is really far too hazardous and unnatural.
      
      #### Approach
      
       * Provide a way for a program to, at runtime, switch to having panics abort.  This makes it possible to panic without making *any* heap allocations, which is needed because on some platforms malloc is UB in a child forked from a multithreaded program (see https://github.com/rust-lang/rust/pull/80263#issuecomment-774272370, and maybe also the SuS [spec](https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html)).
       * Make that change in the child spawned by `Command`.
       * Document the rules comprehensively enough that a programmer has a fighting chance of writing correct code.
       * Test that this all works as expected (and in particular, that there aren't any heap allocations we missed)
      
      Fixes #79740
      
      #### Rejected (or previously attempted) approaches
      
       * Change the panic machinery to be able to unwind without allocating, at least when the payload and message are both `'static`.  This seems like it would be even more subtle.  Also that is a potentially-hot path which I don't want to mess with.
       * Change the existing panic hook mechanism to not convert the message to a `String` before calling the hook.  This would be a surprising change for existing code and would not be detected by the type system.
       * Provide a `raw_panic_hook` function to intercept panics in a way that doesn't allocate.  (That was an earlier version of this MR.)
      
      ### History
      
      This MR could be considered a v2 of #80263.  Thanks to everyone who commented there.  In particular, thanks to `@m-ou-se,` `@Mark-Simulacrum` and `@hyd-dev.`  (Tagging you since I think you might be interested in this new MR.)  Compared to #80263, this MR has very substantial changes and additions.
      
      Additionally, I have recently (2021-04-20) completely revised this series following very helpful comments from `@m-ou-se.`
      
      r? `@m-ou-se`
      d565c748
    • B
      Auto merge of #84920 - Aaron1011:pretty-print-rental, r=petrochenkov · 8cf990c9
      bors 提交于
      Remove some unncessary spaces from pretty-printed tokenstream output
      
      In addition to making the output look nicer for all crates, this also
      aligns the pretty-printing output with what the `rental` crate expects.
      This will allow us to eventually disable a backwards-compat hack in a
      follow-up PR.
      
      See https://github.com/rust-lang/rust/issues/84428 for some background information about why we want to make this change. Note that this change would be desirable (but not particularly necessary) even if `rental` didn't exist, so we're not adding any crate-specific hacks into the compiler.
      8cf990c9
    • B
      Auto merge of #85335 - GuillaumeGomez:rollup-0tvc14g, r=GuillaumeGomez · 50f2bf6a
      bors 提交于
      Rollup of 4 pull requests
      
      Successful merges:
      
       - #84751 (str::is_char_boundary - slight optimization)
       - #85185 (Generate not more docs than necessary)
       - #85324 (Warn about unused `pub` fields in non-`pub` structs)
       - #85329 (fix version_str comment)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      50f2bf6a
    • A
      Remove some unncessary spaces from pretty-printed tokenstream output · 357c013f
      Aaron Hill 提交于
      In addition to making the output look nicer for all crates, this also
      aligns the pretty-printing output with what the `rental` crate expects.
      This will allow us to eventually disable a backwards-compat hack in a
      follow-up PR.
      357c013f
  2. 15 5月, 2021 35 次提交