Skip to content

Commit 71ce4c3

Browse files
committed
Try harder to parse invalid UTF8 on Windows
1 parent 3cd3a2e commit 71ce4c3

File tree

3 files changed

+49
-29
lines changed

3 files changed

+49
-29
lines changed

azure-pipelines.yml

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ trigger: ["master"]
1010
pr: ["master"]
1111

1212
jobs:
13-
- job: DockerLinux
13+
- job: DockerLinux0
1414
dependsOn: StyleAndDocs
1515
pool:
1616
vmImage: ubuntu-16.04
@@ -25,8 +25,6 @@ jobs:
2525
displayName: Execute run-docker.sh
2626
strategy:
2727
matrix:
28-
i586-unknown-linux-gnu:
29-
TARGET: i586-unknown-linux-gnu
3028
i686-unknown-linux-gnu:
3129
TARGET: i686-unknown-linux-gnu
3230
x86_64-unknown-linux-gnu:
@@ -35,14 +33,8 @@ jobs:
3533
TARGET: x86_64-unknown-linux-gnu-emulated
3634
STDARCH_TEST_EVERYTHING: 1
3735
RUSTFLAGS: --cfg stdarch_intel_sde
38-
x86_64-linux-android:
39-
TARGET: x86_64-linux-android
40-
STDARCH_DISABLE_ASSERT_INSTR: 1
4136
arm-unknown-linux-gnueabihf:
4237
TARGET: arm-unknown-linux-gnueabihf
43-
arm-linux-androideabi:
44-
TARGET: arm-linux-androideabi
45-
STDARCH_DISABLE_ASSERT_INSTR: 1
4638
armv7-unknown-linux-gnueabihf:
4739
TARGET: armv7-unknown-linux-gnueabihf
4840
RUSTFLAGS: -C target-feature=+neon
@@ -51,15 +43,46 @@ jobs:
5143
mips-unknown-linux-gnu:
5244
TARGET: mips-unknown-linux-gnu
5345
NORUN: 1
54-
mipsel-unknown-linux-musl:
55-
TARGET: mipsel-unknown-linux-musl
56-
NORUN: 1
5746
mips64-unknown-linux-gnuabi64:
5847
TARGET: mips64-unknown-linux-gnuabi64
5948
NORUN: 1
6049
mips64el-unknown-linux-gnuabi64:
6150
TARGET: mips64el-unknown-linux-gnuabi64
6251
NORUN: 1
52+
powerpc64le-unknown-linux-gnu:
53+
TARGET: powerpc64le-unknown-linux-gnu
54+
STDARCH_DISABLE_ASSERT_INSTR: 1
55+
s390x-unknown-linux-gnu:
56+
TARGET: s390x-unknown-linux-gnu
57+
wasm32-unknown-unknown:
58+
TARGET: wasm32-unknown-unknown
59+
60+
- job: DockerLinux1
61+
dependsOn: DockerLinux0
62+
pool:
63+
vmImage: ubuntu-16.04
64+
steps:
65+
- template: ci/azure-install-rust.yml
66+
- bash: |
67+
if [ "${NO_DOCKER}" = "1" ]; then
68+
ci/run.sh $TARGET
69+
else
70+
ci/run-docker.sh $TARGET
71+
fi
72+
displayName: Execute run-docker.sh
73+
strategy:
74+
matrix:
75+
i586-unknown-linux-gnu:
76+
TARGET: i586-unknown-linux-gnu
77+
x86_64-linux-android:
78+
TARGET: x86_64-linux-android
79+
STDARCH_DISABLE_ASSERT_INSTR: 1
80+
arm-linux-androideabi:
81+
TARGET: arm-linux-androideabi
82+
STDARCH_DISABLE_ASSERT_INSTR: 1
83+
mipsel-unknown-linux-musl:
84+
TARGET: mipsel-unknown-linux-musl
85+
NORUN: 1
6386
aarch64-linux-android:
6487
TARGET: aarch64-linux-android
6588
STDARCH_DISABLE_ASSERT_INSTR: 1
@@ -69,13 +92,6 @@ jobs:
6992
#powerpc64-unknown-linux-gnu:
7093
# TARGET: powerpc64-unknown-linux-gnu
7194
# STDARCH_DISABLE_ASSERT_INSTR: 1
72-
powerpc64le-unknown-linux-gnu:
73-
TARGET: powerpc64le-unknown-linux-gnu
74-
STDARCH_DISABLE_ASSERT_INSTR: 1
75-
s390x-unknown-linux-gnu:
76-
TARGET: s390x-unknown-linux-gnu
77-
wasm32-unknown-unknown:
78-
TARGET: wasm32-unknown-unknown
7995
nvptx64-nvidia-cuda:
8096
TARGET: nvptx64-nvidia-cuda
8197
NORUN: 1
@@ -136,14 +152,17 @@ jobs:
136152
displayName: Execute run.sh
137153
strategy:
138154
matrix:
139-
x86_64-pc-windows-gnu:
140-
TARGET: x86_64-pc-windows-gnu
141155
x86_64-pc-windows-msvc:
142156
TARGET: x86_64-pc-windows-msvc
143-
i686-pc-windows-gnu:
144-
TARGET: i686-pc-windows-gnu
145-
i686-pc-windows-msvc:
146-
TARGET: i686-pc-windows-msvc
157+
# FIXME:
158+
# Disassembly no implemented for the
159+
# following targets:
160+
# x86_64-pc-windows-gnu:
161+
# TARGET: x86_64-pc-windows-gnu
162+
#i686-pc-windows-gnu:
163+
# TARGET: i686-pc-windows-gnu
164+
#i686-pc-windows-msvc:
165+
# TARGET: i686-pc-windows-msvc
147166

148167
- job: StyleAndDocs
149168
pool:

crates/stdarch-test/src/disassembly.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(crate) fn disassemble_myself() -> HashSet<Function> {
5858
);
5959
assert!(output.status.success());
6060
// Windows does not return valid UTF-8 output:
61-
Ok(String::from_utf8_lossy(&output.stderr).to_string())
61+
String::from_utf8_lossy(Vec::leak(output.stdout))
6262
} else if cfg!(target_os = "windows") {
6363
panic!("disassembly unimplemented")
6464
} else if cfg!(target_os = "macos") {
@@ -74,7 +74,7 @@ pub(crate) fn disassemble_myself() -> HashSet<Function> {
7474
);
7575
assert!(output.status.success());
7676

77-
String::from_utf8(output.stdout)
77+
String::from_utf8_lossy(Vec::leak(output.stdout))
7878
} else {
7979
let objdump =
8080
env::var("OBJDUMP").unwrap_or_else(|_| "objdump".to_string());
@@ -93,8 +93,8 @@ pub(crate) fn disassemble_myself() -> HashSet<Function> {
9393
);
9494
assert!(output.status.success());
9595

96-
String::from_utf8(output.stdout)
97-
}.expect("failed to convert to utf8");
96+
String::from_utf8_lossy(Vec::leak(output.stdout))
97+
};
9898

9999
parse(&disassembly)
100100
}

crates/stdarch-test/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! assertions about the disassembly of a function.
66
#![feature(const_str_as_bytes)]
77
#![feature(const_transmute)]
8+
#![feature(vec_leak)]
89
#![allow(clippy::missing_docs_in_private_items, clippy::print_stdout)]
910

1011
extern crate assert_instr_macro;

0 commit comments

Comments
 (0)