Skip to content

run: Process::new() should take &[Str] instead of &[~str] for args#8203

Closed
lilyball wants to merge 1 commit into
rust-lang:masterfrom
lilyball:process-new-args
Closed

run: Process::new() should take &[Str] instead of &[~str] for args#8203
lilyball wants to merge 1 commit into
rust-lang:masterfrom
lilyball:process-new-args

Conversation

@lilyball

@lilyball lilyball commented Aug 1, 2013

Copy link
Copy Markdown
Contributor

Fixes #7928.

As a side-effect, this no longer clones all the arg strings on unix.

@lilyball

lilyball commented Aug 2, 2013

Copy link
Copy Markdown
Contributor Author

@graydon: Upon thinking more about the ugly code in with_argv I'm no longer convinced that my replacement is safe. Specifically, as_c_str may actually copy the string if it's not null-terminated, and provide a pointer to that copied string. I suspect I may have to go ahead and use my new into_owned() so I can then use as_bytes_with_null() instead, although this will mean copying strings even if they were null-terminated to begin with.

Alternatively I could reimplement as_c_str() but have it return (Option<~str>, *libc::c_char) instead, which would let me hold onto the temporary if one was constructed.

Thoughts?

@lilyball

lilyball commented Aug 2, 2013

Copy link
Copy Markdown
Contributor Author

@graydon: I deleted your r+ comment due to the above issue.

@lilyball

lilyball commented Aug 2, 2013

Copy link
Copy Markdown
Contributor Author

@graydon: r? I fixed with_argv to only copy arguments when necessary.

@graydon

graydon commented Aug 2, 2013

Copy link
Copy Markdown
Contributor

Needs a rebase. Otherwise r=me, yeah. This is something I thought wouldn't be a problem at first since you were asking about a code change when the incoming values were all ~str and then I overlooked that later you were using it as a way to abstract it to take Str. Sorry.

@lilyball

lilyball commented Aug 2, 2013

Copy link
Copy Markdown
Contributor Author

r? @graydon

bors added a commit that referenced this pull request Aug 3, 2013
The method .into_owned() is meant to be used as an optimization when you
need to get a ~str from a Str, but don't want to unnecessarily copy it
if it's already a ~str.

This is meant to ease functions that look like

  fn foo<S: Str>(strs: &[S])

Previously they could work with the strings as slices using .as_slice(),
but producing ~str required copying the string, even if the vector
turned out be a &[~str] already.

I don't have any concrete uses for this yet, since the one conversion I've done to `&[S]` so far (see PR #8203) didn't actually need owned strings. But having this here may make using `Str` more attractive.

It also may be worth adding an `into_managed()` function, but that one is less obviously useful than `into_owned()`.
@graydon

graydon commented Aug 6, 2013

Copy link
Copy Markdown
Contributor

The bad news is that we just (today) agreed to take the patch that removes the trailing nulls from slices and sets their length back to always cover only valid chars. This means that (a) you'll always need to copy and (b) if you use that probe-one-past-the-end code you copied and pasted in here, it'll start causing memory faults.

Sorry about this mess. Confusion around the trailing nulls is exactly the thing we are trying to get rid of, by removing the feature.

@lilyball

lilyball commented Aug 6, 2013

Copy link
Copy Markdown
Contributor Author

Holding this patch until #8296 lands, at which point I will rewrite this on top of it.

@lilyball

Copy link
Copy Markdown
Contributor Author

Rewritten on top of #8296. r? @graydon

@lilyball

Copy link
Copy Markdown
Contributor Author

@graydon There was one error in librust, which I didn't catch because I only ran the libstd tests instead of doing a full build. My bad. r?

@lilyball

Copy link
Copy Markdown
Contributor Author

Rebased yet again.

@catamorphism

Copy link
Copy Markdown
Contributor

@kballard Needs rebase (and the test failure may be legitimate, I'm not sure)

@lilyball

Copy link
Copy Markdown
Contributor Author

Rebased. Don't understand the test failures though. Nothing I did should affect Windows linkage, or should add calls to Windows functions that weren't previously used.

@lilyball

Copy link
Copy Markdown
Contributor Author

I have no idea what's causing the Windows failures:

error: linking with `g++` failed with code 1
note: g++ arguments: -Lc:\bot\slave\auto-win-32-nopt-t\build\obj\i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin -m32 -o i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin\extra-a7c050cfd46b2c9a-0.8-pre.dll i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin\extra.o -Lc:\bot\slave\auto-win-32-nopt-t\build\obj\i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin -lstd-6c65cf4b443341b1-0.8-pre -Lc:\bot\slave\auto-win-32-nopt-t\build\obj\.rust -Lc:\bot\slave\auto-win-32-nopt-t\build\obj -shared -lmorestack -lrustrt
note: i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin\extra.o:fake:(.text+0x8d83c): undefined reference to `GetCurrentProcess'
i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin\extra.o:fake:(.text+0x8d963): undefined reference to `DuplicateHandle'
i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin\extra.o:fake:(.text+0x8db74): undefined reference to `DuplicateHandle'
i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin\extra.o:fake:(.text+0x8dd85): undefined reference to `DuplicateHandle'
i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin\extra.o:fake:(.text+0x8eb67): undefined reference to `CloseHandle'
i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin\extra.o:fake:(.text+0x8eb79): undefined reference to `CloseHandle'
i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin\extra.o:fake:(.text+0x8eb8b): undefined reference to `CloseHandle'
i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin\extra.o:fake:(.text+0x8ec50): undefined reference to `CloseHandle'
i686-pc-mingw32\stage1\bin\rustc\i686-pc-mingw32\bin\extra.o:fake:(.text+0x8f031): undefined reference to `CreateProcessA'
collect2: ld returned 1 exit status

@lilyball

Copy link
Copy Markdown
Contributor Author

The referenced calls are all used in spawn_process_os(). The only change I made to that function was changing the type of the args arg from &[~str] to &[S] where S: Str.

@catamorphism

Copy link
Copy Markdown
Contributor

@kballard Needs a rebase in any case.

@lilyball

Copy link
Copy Markdown
Contributor Author

@catamorphism I can rebase it yet again, but that won't solve the windows problem. My best guess right now is that there's something going on here where the fact that it's generic means that libstd isn't actually linking against the FFI functions (because it contains the AST for the function instead of the actual compiled executable code), and then when libextra tries to call it, it hits the undefined symbols.

@lilyball

Copy link
Copy Markdown
Contributor Author

It appears that process spawning has changed significantly. I'm going to re-write this PR on top of the new approach, but I don't know if the Windows issue will continue to happen. I wish I had some way of testing without going through the full r+ process.

@lilyball

Copy link
Copy Markdown
Contributor Author

Looks like the new approach no longer defines the Windows FFI functions as part of the process stuff, instead relying on libuv to deal with it, so I hope that means it won't happen again.

@lilyball

Copy link
Copy Markdown
Contributor Author

I have a rewritten version now that passes the stage2 libstd tests, but I'm running make check before pushing it.

@lilyball

Copy link
Copy Markdown
Contributor Author

Don't review yet. Pushing here because I'm having a compilation issue.

@lilyball

Copy link
Copy Markdown
Contributor Author

Ok this new commit passes make check. Sadly I had to leave run::process_status() as taking &[~str], because of the ICE in #8835.

@lilyball

Copy link
Copy Markdown
Contributor Author

r?

@alexcrichton

Copy link
Copy Markdown
Member

Sorry about std::run being in such flux and for causing all the bounces. The change to libuv and process bindings has now been reverted, so this shouldn't bounce any more. It needs a rebase though :(

@lilyball

Copy link
Copy Markdown
Contributor Author

@alexcrichton Why was it reverted? Was that the source of the crashes on the builders?

Anyway, going back to the previous implementation of this is just going to bring back the Windows test failures. My guess right now is there's a problem with declaring extern fns inside a generic fn. I could try refactoring those declarations to be outside the generic fn, but I have no way of test Windows short of going through the whole r+ -> full make check process again.

@alexcrichton

Copy link
Copy Markdown
Member

It was both the source of a massive regression on windows and I also suspect that it was causing all the segfaults.

For you extern fn inside a generic fn problem, I'd be interested in seeing if #8843 fixes that issue.

@lilyball

Copy link
Copy Markdown
Contributor Author

Rebased. This presumably is going to require #8843 to work on Windows though.

@huonw

huonw commented Aug 30, 2013

Copy link
Copy Markdown
Contributor

@kballard #8843 has now landed.

@lilyball

Copy link
Copy Markdown
Contributor Author

@huonw Great. This can be reviewed again now.

@lilyball

Copy link
Copy Markdown
Contributor Author

Damn. #8843 didn't fix it.

@catamorphism

Copy link
Copy Markdown
Contributor

Closing due to lack of activity. Please reopen a new pull request if you get the chance to work on this more -- thanks!

@lilyball

Copy link
Copy Markdown
Contributor Author

It seems #9055 may be the cause of the Windows errors.

@lilyball lilyball deleted the process-new-args branch May 16, 2014 02:21
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jan 17, 2022
New lint: `iter_overeager_cloned`

Closes rust-lang#8202

changelog: New lint: [`iter_overeager_cloned`]
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 18, 2026
…kout-6.x, r=marcoieni

Update actions/checkout action to v6

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/checkout](https://redirect.github.com/actions/checkout) | action | major | `v5` → `v6.0.3` |

---

### Release Notes

<details>
<summary>actions/checkout (actions/checkout)</summary>

### [`v6.0.3`](https://redirect.github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v603)

[Compare Source](https://redirect.github.com/actions/checkout/compare/v6.0.2...v6.0.3)

- Fix checkout init for SHA-256 repositories by [@&rust-lang#8203;yaananth](https://redirect.github.com/yaananth) in [#&rust-lang#8203;2439](https://redirect.github.com/actions/checkout/pull/2439)
- fix: expand merge commit SHA regex and add SHA-256 test cases by [@&rust-lang#8203;yaananth](https://redirect.github.com/yaananth) in [#&rust-lang#8203;2414](https://redirect.github.com/actions/checkout/pull/2414)

### [`v6.0.2`](https://redirect.github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v602)

[Compare Source](https://redirect.github.com/actions/checkout/compare/v6.0.1...v6.0.2)

- Fix tag handling: preserve annotations and explicit fetch-tags by [@&rust-lang#8203;ericsciple](https://redirect.github.com/ericsciple) in [#&rust-lang#8203;2356](https://redirect.github.com/actions/checkout/pull/2356)

### [`v6.0.1`](https://redirect.github.com/actions/checkout/compare/v6.0.0...v6.0.1)

[Compare Source](https://redirect.github.com/actions/checkout/compare/v6...v6.0.1)

### [`v6.0.0`](https://redirect.github.com/actions/checkout/compare/v5.0.1...v6.0.0)

[Compare Source](https://redirect.github.com/actions/checkout/compare/v5.0.1...v6)

### [`v5.0.1`](https://redirect.github.com/actions/checkout/releases/tag/v5.0.1)

[Compare Source](https://redirect.github.com/actions/checkout/compare/v5...v5.0.1)

##### What's Changed

- Port v6 cleanup to v5 by [@&rust-lang#8203;ericsciple](https://redirect.github.com/ericsciple) in [#&rust-lang#8203;2301](https://redirect.github.com/actions/checkout/pull/2301)

**Full Changelog**: <actions/checkout@v5...v5.0.1>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/rust-lang/rust).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMTkuMCIsInVwZGF0ZWRJblZlciI6IjQzLjIxOS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 21, 2026
…load-artifact-8.x, r=Mark-Simulacrum

Update actions/download-artifact action to v8.0.1

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/download-artifact](https://redirect.github.com/actions/download-artifact) | action | patch | `v8` → `v8.0.1` |

---

### Release Notes

<details>
<summary>actions/download-artifact (actions/download-artifact)</summary>

### [`v8.0.1`](https://redirect.github.com/actions/download-artifact/releases/tag/v8.0.1)

[Compare Source](https://redirect.github.com/actions/download-artifact/compare/v8...v8.0.1)

#### What's Changed

- Support for CJK characters in the artifact name by [@&rust-lang#8203;danwkennedy](https://redirect.github.com/danwkennedy) in [#&rust-lang#8203;471](https://redirect.github.com/actions/download-artifact/pull/471)
- Add a regression test for artifact name + content-type mismatches by [@&rust-lang#8203;danwkennedy](https://redirect.github.com/danwkennedy) in [#&rust-lang#8203;472](https://redirect.github.com/actions/download-artifact/pull/472)

**Full Changelog**: <actions/download-artifact@v8...v8.0.1>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/rust-lang/rust).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMzEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjIzMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 21, 2026
…load-artifact-8.x, r=Mark-Simulacrum

Update actions/download-artifact action to v8.0.1

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/download-artifact](https://redirect.github.com/actions/download-artifact) | action | patch | `v8` → `v8.0.1` |

---

### Release Notes

<details>
<summary>actions/download-artifact (actions/download-artifact)</summary>

### [`v8.0.1`](https://redirect.github.com/actions/download-artifact/releases/tag/v8.0.1)

[Compare Source](https://redirect.github.com/actions/download-artifact/compare/v8...v8.0.1)

#### What's Changed

- Support for CJK characters in the artifact name by [@&rust-lang#8203;danwkennedy](https://redirect.github.com/danwkennedy) in [#&rust-lang#8203;471](https://redirect.github.com/actions/download-artifact/pull/471)
- Add a regression test for artifact name + content-type mismatches by [@&rust-lang#8203;danwkennedy](https://redirect.github.com/danwkennedy) in [#&rust-lang#8203;472](https://redirect.github.com/actions/download-artifact/pull/472)

**Full Changelog**: <actions/download-artifact@v8...v8.0.1>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/rust-lang/rust).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMzEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjIzMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
rust-timer added a commit that referenced this pull request Jun 22, 2026
Rollup merge of #158108 - renovate-bot:renovate/actions-download-artifact-8.x, r=Mark-Simulacrum

Update actions/download-artifact action to v8.0.1

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/download-artifact](https://redirect.github.com/actions/download-artifact) | action | patch | `v8` → `v8.0.1` |

---

### Release Notes

<details>
<summary>actions/download-artifact (actions/download-artifact)</summary>

### [`v8.0.1`](https://redirect.github.com/actions/download-artifact/releases/tag/v8.0.1)

[Compare Source](https://redirect.github.com/actions/download-artifact/compare/v8...v8.0.1)

#### What's Changed

- Support for CJK characters in the artifact name by [@&#8203;danwkennedy](https://redirect.github.com/danwkennedy) in [#&#8203;471](https://redirect.github.com/actions/download-artifact/pull/471)
- Add a regression test for artifact name + content-type mismatches by [@&#8203;danwkennedy](https://redirect.github.com/danwkennedy) in [#&#8203;472](https://redirect.github.com/actions/download-artifact/pull/472)

**Full Changelog**: <actions/download-artifact@v8...v8.0.1>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/rust-lang/rust).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMzEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjIzMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
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.

std::run::Process::new() should take &[&str] instead of &[~str]

7 participants