From abae168e2f90b4801732a174d9c2447bf1bb092b Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Wed, 20 Dec 2023 17:59:00 +0300 Subject: [PATCH 1/4] if source is git, make /checkout dir safe for git Signed-off-by: onur-ozkan --- src/ci/docker/run.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 636692a0954ac..2573bf1309efc 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -36,6 +36,11 @@ root_dir="`dirname $src_dir`" objdir=$root_dir/obj dist=$objdir/build/dist + +if [ -d "$root_dir/.git" ]; then + IS_GIT_SOURCE=1 +fi + source "$ci_dir/shared.sh" CACHE_DOMAIN="${CACHE_DOMAIN:-ci-caches.rust-lang.org}" @@ -249,9 +254,13 @@ if [ "$dev" = "1" ] then # Interactive + TTY args="$args -it" - command="/bin/bash" + if [ $IS_GIT_SOURCE -eq 1 ]; then + command=(/bin/bash -c 'git config --global --add safe.directory /checkout;bash') + else + command=(/bin/bash) + fi else - command="/checkout/src/ci/run.sh" + command=(/checkout/src/ci/run.sh) fi if [ "$CI" != "" ]; then @@ -301,7 +310,7 @@ docker \ --init \ --rm \ rust-ci \ - $command + "${command[@]}" cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}" From f2e711e4c22a2fec34b6a1e61499a09a071a84e4 Mon Sep 17 00:00:00 2001 From: Kent Ross Date: Thu, 21 Dec 2023 15:17:53 -0800 Subject: [PATCH 2/4] fix minor mistake in comments describing VecDeque resizing --- library/alloc/src/collections/vec_deque/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 4ef8af9b03475..d062587b8f533 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -491,12 +491,12 @@ impl VecDeque { // A [o o o o o o o . . . . . . . . . ] // L H // [o o o o o o o o ] - // H L - // B [. . . o o o o o o o . . . . . . ] + // H L + // B [. . . o o o o o o o o . . . . . ] // L H // [o o o o o o o o ] - // L H - // C [o o o o o . . . . . . . . . o o ] + // L H + // C [o o o o o o . . . . . . . . o o ] // can't use is_contiguous() because the capacity is already updated. if self.head <= old_capacity - self.len { From c83bcbbad9f09acc72093b1b5681a6d22fb7b524 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 23 Dec 2023 16:48:29 +0100 Subject: [PATCH 3/4] interpret/memory: explain why we check is_thread_local_static --- compiler/rustc_const_eval/src/interpret/memory.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 3fde6ae9b8ea6..7ff970661d6f1 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -165,6 +165,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { // We need to handle `extern static`. match self.tcx.try_get_global_alloc(alloc_id) { Some(GlobalAlloc::Static(def_id)) if self.tcx.is_thread_local_static(def_id) => { + // Thread-local statics do not have a constant address. They *must* be accessed via + // `ThreadLocalRef`; we can never have a pointer to them as a regular constant value. bug!("global memory cannot point to thread-local static") } Some(GlobalAlloc::Static(def_id)) if self.tcx.is_foreign_item(def_id) => { @@ -539,6 +541,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { None => throw_ub!(PointerUseAfterFree(id, CheckInAllocMsg::MemoryAccessTest)), Some(GlobalAlloc::Static(def_id)) => { assert!(self.tcx.is_static(def_id)); + // Thread-local statics do not have a constant address. They *must* be accessed via + // `ThreadLocalRef`; we can never have a pointer to them as a regular constant value. assert!(!self.tcx.is_thread_local_static(def_id)); // Notice that every static has two `AllocId` that will resolve to the same // thing here: one maps to `GlobalAlloc::Static`, this is the "lazy" ID, @@ -740,6 +744,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { match self.tcx.try_get_global_alloc(id) { Some(GlobalAlloc::Static(def_id)) => { assert!(self.tcx.is_static(def_id)); + // Thread-local statics do not have a constant address. They *must* be accessed via + // `ThreadLocalRef`; we can never have a pointer to them as a regular constant value. assert!(!self.tcx.is_thread_local_static(def_id)); // Use size and align of the type. let ty = self From b498489c13686644e7fac1f2b686404a307adcbd Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Wed, 20 Dec 2023 18:20:18 +0300 Subject: [PATCH 4/4] allow devs to turn-off read-only mode Signed-off-by: onur-ozkan --- src/ci/docker/run.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 2573bf1309efc..55eed95492d3e 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -199,6 +199,14 @@ else args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache" fi +# By default, container volumes are bound as read-only; therefore doing experimental work +# or debugging within the container environment (such as fetching submodules and +# building them) is not possible. Setting READ_ONLY_SRC to 0 enables this capability by +# binding the volumes in read-write mode. +if [ "$READ_ONLY_SRC" != "0" ]; then + SRC_MOUNT_OPTION=":ro" +fi + # Run containers as privileged as it should give them access to some more # syscalls such as ptrace and whatnot. In the upgrade to LLVM 5.0 it was # discovered that the leak sanitizer apparently needs these syscalls nowadays so @@ -233,7 +241,7 @@ if [ -f /.dockerenv ]; then docker cp . checkout:/checkout args="$args --volumes-from checkout" else - args="$args --volume $root_dir:/checkout:ro" + args="$args --volume $root_dir:/checkout$SRC_MOUNT_OPTION" args="$args --volume $objdir:/checkout/obj" args="$args --volume $HOME/.cargo:/cargo" args="$args --volume $HOME/rustsrc:$HOME/rustsrc"