From c69e0c2a9bb652ea425da3546159a19255f11381 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 3 Aug 2023 18:45:04 +0000 Subject: Move `fail` tests that need dependencies into their own folder, so that wasm tests don't build dependencies --- src/tools/miri/tests/compiletest.rs | 6 +++ .../libc_pthread_create_main_terminate.rs | 19 +++++++++ .../libc_pthread_create_main_terminate.stderr | 6 +++ .../libc_pthread_create_too_few_args.rs | 22 ++++++++++ .../libc_pthread_create_too_few_args.stderr | 14 +++++++ .../libc_pthread_create_too_many_args.rs | 22 ++++++++++ .../libc_pthread_create_too_many_args.stderr | 14 +++++++ .../concurrency/libc_pthread_join_detached.rs | 20 +++++++++ .../concurrency/libc_pthread_join_detached.stderr | 15 +++++++ .../concurrency/libc_pthread_join_joined.rs | 20 +++++++++ .../concurrency/libc_pthread_join_joined.stderr | 15 +++++++ .../fail-dep/concurrency/libc_pthread_join_main.rs | 16 ++++++++ .../concurrency/libc_pthread_join_main.stderr | 15 +++++++ .../concurrency/libc_pthread_join_multiple.rs | 29 +++++++++++++ .../concurrency/libc_pthread_join_multiple.stderr | 15 +++++++ .../fail-dep/concurrency/libc_pthread_join_self.rs | 18 +++++++++ .../concurrency/libc_pthread_join_self.stderr | 15 +++++++ .../fail-dep/concurrency/unwind_top_of_stack.rs | 29 +++++++++++++ .../concurrency/unwind_top_of_stack.stderr | 21 ++++++++++ .../miri/tests/fail-dep/shims/fs/close_stdout.rs | 10 +++++ .../tests/fail-dep/shims/fs/close_stdout.stderr | 14 +++++++ .../miri/tests/fail-dep/shims/fs/isolated_stdin.rs | 9 +++++ .../tests/fail-dep/shims/fs/isolated_stdin.stderr | 15 +++++++ .../fail-dep/shims/fs/mkstemp_immutable_arg.rs | 11 +++++ .../fail-dep/shims/fs/mkstemp_immutable_arg.stderr | 20 +++++++++ .../tests/fail-dep/shims/fs/read_from_stdout.rs | 10 +++++ .../fail-dep/shims/fs/read_from_stdout.stderr | 14 +++++++ .../shims/fs/unix_open_missing_required_mode.rs | 12 ++++++ .../fs/unix_open_missing_required_mode.stderr | 20 +++++++++ .../miri/tests/fail-dep/shims/fs/write_to_stdin.rs | 9 +++++ .../tests/fail-dep/shims/fs/write_to_stdin.stderr | 14 +++++++ src/tools/miri/tests/fail-dep/shims/memchr_null.rs | 10 +++++ .../miri/tests/fail-dep/shims/memchr_null.stderr | 15 +++++++ src/tools/miri/tests/fail-dep/shims/memcmp_null.rs | 10 +++++ .../miri/tests/fail-dep/shims/memcmp_null.stderr | 15 +++++++ src/tools/miri/tests/fail-dep/shims/memcmp_zero.rs | 13 ++++++ .../miri/tests/fail-dep/shims/memcmp_zero.stderr | 15 +++++++ src/tools/miri/tests/fail-dep/shims/memcpy_zero.rs | 12 ++++++ .../miri/tests/fail-dep/shims/memcpy_zero.stderr | 15 +++++++ .../miri/tests/fail-dep/shims/memrchr_null.rs | 11 +++++ .../miri/tests/fail-dep/shims/memrchr_null.stderr | 15 +++++++ .../tests/fail-dep/shims/mmap_invalid_dealloc.rs | 18 +++++++++ .../fail-dep/shims/mmap_invalid_dealloc.stderr | 15 +++++++ .../tests/fail-dep/shims/mmap_use_after_munmap.rs | 19 +++++++++ .../fail-dep/shims/mmap_use_after_munmap.stderr | 47 ++++++++++++++++++++++ src/tools/miri/tests/fail-dep/shims/munmap.rs | 22 ++++++++++ src/tools/miri/tests/fail-dep/shims/munmap.stderr | 39 ++++++++++++++++++ .../miri/tests/fail-dep/shims/munmap_partial.rs | 18 +++++++++ .../tests/fail-dep/shims/munmap_partial.stderr | 29 +++++++++++++ .../shims/sync/libc_pthread_cond_double_destroy.rs | 20 +++++++++ .../sync/libc_pthread_cond_double_destroy.stderr | 15 +++++++ .../sync/libc_pthread_condattr_double_destroy.rs | 17 ++++++++ .../libc_pthread_condattr_double_destroy.stderr | 15 +++++++ .../shims/sync/libc_pthread_mutex_NULL_deadlock.rs | 12 ++++++ .../sync/libc_pthread_mutex_NULL_deadlock.stderr | 15 +++++++ .../shims/sync/libc_pthread_mutex_deadlock.rs | 28 +++++++++++++ .../shims/sync/libc_pthread_mutex_deadlock.stderr | 12 ++++++ .../sync/libc_pthread_mutex_default_deadlock.rs | 13 ++++++ .../libc_pthread_mutex_default_deadlock.stderr | 15 +++++++ .../sync/libc_pthread_mutex_destroy_locked.rs | 15 +++++++ .../sync/libc_pthread_mutex_destroy_locked.stderr | 15 +++++++ .../sync/libc_pthread_mutex_double_destroy.rs | 21 ++++++++++ .../sync/libc_pthread_mutex_double_destroy.stderr | 15 +++++++ .../sync/libc_pthread_mutex_normal_deadlock.rs | 15 +++++++ .../sync/libc_pthread_mutex_normal_deadlock.stderr | 12 ++++++ .../libc_pthread_mutex_normal_unlock_unlocked.rs | 16 ++++++++ ...ibc_pthread_mutex_normal_unlock_unlocked.stderr | 15 +++++++ .../shims/sync/libc_pthread_mutex_wrong_owner.rs | 28 +++++++++++++ .../sync/libc_pthread_mutex_wrong_owner.stderr | 15 +++++++ .../sync/libc_pthread_mutexattr_double_destroy.rs | 17 ++++++++ .../libc_pthread_mutexattr_double_destroy.stderr | 15 +++++++ .../libc_pthread_rwlock_destroy_read_locked.rs | 9 +++++ .../libc_pthread_rwlock_destroy_read_locked.stderr | 15 +++++++ .../libc_pthread_rwlock_destroy_write_locked.rs | 9 +++++ ...libc_pthread_rwlock_destroy_write_locked.stderr | 15 +++++++ .../sync/libc_pthread_rwlock_double_destroy.rs | 14 +++++++ .../sync/libc_pthread_rwlock_double_destroy.stderr | 15 +++++++ ...ead_rwlock_read_write_deadlock_single_thread.rs | 9 +++++ ...rwlock_read_write_deadlock_single_thread.stderr | 12 ++++++ .../sync/libc_pthread_rwlock_read_wrong_owner.rs | 28 +++++++++++++ .../libc_pthread_rwlock_read_wrong_owner.stderr | 15 +++++++ .../sync/libc_pthread_rwlock_unlock_unlocked.rs | 8 ++++ .../libc_pthread_rwlock_unlock_unlocked.stderr | 15 +++++++ .../libc_pthread_rwlock_write_read_deadlock.rs | 28 +++++++++++++ .../libc_pthread_rwlock_write_read_deadlock.stderr | 12 ++++++ ...ead_rwlock_write_read_deadlock_single_thread.rs | 9 +++++ ...rwlock_write_read_deadlock_single_thread.stderr | 12 ++++++ .../libc_pthread_rwlock_write_write_deadlock.rs | 28 +++++++++++++ ...libc_pthread_rwlock_write_write_deadlock.stderr | 12 ++++++ ...ad_rwlock_write_write_deadlock_single_thread.rs | 9 +++++ ...wlock_write_write_deadlock_single_thread.stderr | 12 ++++++ .../sync/libc_pthread_rwlock_write_wrong_owner.rs | 28 +++++++++++++ .../libc_pthread_rwlock_write_wrong_owner.stderr | 15 +++++++ src/tools/miri/tests/fail-dep/tokio/sleep.rs | 14 +++++++ src/tools/miri/tests/fail-dep/tokio/sleep.stderr | 15 +++++++ .../fail-dep/unsupported_incomplete_function.rs | 11 +++++ .../unsupported_incomplete_function.stderr | 14 +++++++ .../libc_pthread_create_main_terminate.rs | 19 --------- .../libc_pthread_create_main_terminate.stderr | 6 --- .../libc_pthread_create_too_few_args.rs | 22 ---------- .../libc_pthread_create_too_few_args.stderr | 14 ------- .../libc_pthread_create_too_many_args.rs | 22 ---------- .../libc_pthread_create_too_many_args.stderr | 14 ------- .../fail/concurrency/libc_pthread_join_detached.rs | 20 --------- .../concurrency/libc_pthread_join_detached.stderr | 15 ------- .../fail/concurrency/libc_pthread_join_joined.rs | 20 --------- .../concurrency/libc_pthread_join_joined.stderr | 15 ------- .../fail/concurrency/libc_pthread_join_main.rs | 16 -------- .../fail/concurrency/libc_pthread_join_main.stderr | 15 ------- .../fail/concurrency/libc_pthread_join_multiple.rs | 29 ------------- .../concurrency/libc_pthread_join_multiple.stderr | 15 ------- .../fail/concurrency/libc_pthread_join_self.rs | 18 --------- .../fail/concurrency/libc_pthread_join_self.stderr | 15 ------- .../tests/fail/concurrency/unwind_top_of_stack.rs | 29 ------------- .../fail/concurrency/unwind_top_of_stack.stderr | 21 ---------- src/tools/miri/tests/fail/shims/fs/close_stdout.rs | 10 ----- .../miri/tests/fail/shims/fs/close_stdout.stderr | 14 ------- .../miri/tests/fail/shims/fs/isolated_stdin.rs | 9 ----- .../miri/tests/fail/shims/fs/isolated_stdin.stderr | 15 ------- .../tests/fail/shims/fs/mkstemp_immutable_arg.rs | 11 ----- .../fail/shims/fs/mkstemp_immutable_arg.stderr | 20 --------- .../miri/tests/fail/shims/fs/read_from_stdout.rs | 10 ----- .../tests/fail/shims/fs/read_from_stdout.stderr | 14 ------- .../shims/fs/unix_open_missing_required_mode.rs | 12 ------ .../fs/unix_open_missing_required_mode.stderr | 20 --------- .../miri/tests/fail/shims/fs/write_to_stdin.rs | 9 ----- .../miri/tests/fail/shims/fs/write_to_stdin.stderr | 14 ------- src/tools/miri/tests/fail/shims/memchr_null.rs | 10 ----- src/tools/miri/tests/fail/shims/memchr_null.stderr | 15 ------- src/tools/miri/tests/fail/shims/memcmp_null.rs | 10 ----- src/tools/miri/tests/fail/shims/memcmp_null.stderr | 15 ------- src/tools/miri/tests/fail/shims/memcmp_zero.rs | 13 ------ src/tools/miri/tests/fail/shims/memcmp_zero.stderr | 15 ------- src/tools/miri/tests/fail/shims/memcpy_zero.rs | 12 ------ src/tools/miri/tests/fail/shims/memcpy_zero.stderr | 15 ------- src/tools/miri/tests/fail/shims/memrchr_null.rs | 11 ----- .../miri/tests/fail/shims/memrchr_null.stderr | 15 ------- .../miri/tests/fail/shims/mmap_invalid_dealloc.rs | 18 --------- .../tests/fail/shims/mmap_invalid_dealloc.stderr | 15 ------- .../miri/tests/fail/shims/mmap_use_after_munmap.rs | 19 --------- .../tests/fail/shims/mmap_use_after_munmap.stderr | 47 ---------------------- src/tools/miri/tests/fail/shims/munmap.rs | 22 ---------- src/tools/miri/tests/fail/shims/munmap.stderr | 39 ------------------ src/tools/miri/tests/fail/shims/munmap_partial.rs | 18 --------- .../miri/tests/fail/shims/munmap_partial.stderr | 29 ------------- .../shims/sync/libc_pthread_cond_double_destroy.rs | 20 --------- .../sync/libc_pthread_cond_double_destroy.stderr | 15 ------- .../sync/libc_pthread_condattr_double_destroy.rs | 17 -------- .../libc_pthread_condattr_double_destroy.stderr | 15 ------- .../shims/sync/libc_pthread_mutex_NULL_deadlock.rs | 12 ------ .../sync/libc_pthread_mutex_NULL_deadlock.stderr | 15 ------- .../fail/shims/sync/libc_pthread_mutex_deadlock.rs | 28 ------------- .../shims/sync/libc_pthread_mutex_deadlock.stderr | 12 ------ .../sync/libc_pthread_mutex_default_deadlock.rs | 13 ------ .../libc_pthread_mutex_default_deadlock.stderr | 15 ------- .../sync/libc_pthread_mutex_destroy_locked.rs | 15 ------- .../sync/libc_pthread_mutex_destroy_locked.stderr | 15 ------- .../sync/libc_pthread_mutex_double_destroy.rs | 21 ---------- .../sync/libc_pthread_mutex_double_destroy.stderr | 15 ------- .../sync/libc_pthread_mutex_normal_deadlock.rs | 15 ------- .../sync/libc_pthread_mutex_normal_deadlock.stderr | 12 ------ .../libc_pthread_mutex_normal_unlock_unlocked.rs | 16 -------- ...ibc_pthread_mutex_normal_unlock_unlocked.stderr | 15 ------- .../shims/sync/libc_pthread_mutex_wrong_owner.rs | 28 ------------- .../sync/libc_pthread_mutex_wrong_owner.stderr | 15 ------- .../sync/libc_pthread_mutexattr_double_destroy.rs | 17 -------- .../libc_pthread_mutexattr_double_destroy.stderr | 15 ------- .../libc_pthread_rwlock_destroy_read_locked.rs | 9 ----- .../libc_pthread_rwlock_destroy_read_locked.stderr | 15 ------- .../libc_pthread_rwlock_destroy_write_locked.rs | 9 ----- ...libc_pthread_rwlock_destroy_write_locked.stderr | 15 ------- .../sync/libc_pthread_rwlock_double_destroy.rs | 14 ------- .../sync/libc_pthread_rwlock_double_destroy.stderr | 15 ------- ...ead_rwlock_read_write_deadlock_single_thread.rs | 9 ----- ...rwlock_read_write_deadlock_single_thread.stderr | 12 ------ .../sync/libc_pthread_rwlock_read_wrong_owner.rs | 28 ------------- .../libc_pthread_rwlock_read_wrong_owner.stderr | 15 ------- .../sync/libc_pthread_rwlock_unlock_unlocked.rs | 8 ---- .../libc_pthread_rwlock_unlock_unlocked.stderr | 15 ------- .../libc_pthread_rwlock_write_read_deadlock.rs | 28 ------------- .../libc_pthread_rwlock_write_read_deadlock.stderr | 12 ------ ...ead_rwlock_write_read_deadlock_single_thread.rs | 9 ----- ...rwlock_write_read_deadlock_single_thread.stderr | 12 ------ .../libc_pthread_rwlock_write_write_deadlock.rs | 28 ------------- ...libc_pthread_rwlock_write_write_deadlock.stderr | 12 ------ ...ad_rwlock_write_write_deadlock_single_thread.rs | 9 ----- ...wlock_write_write_deadlock_single_thread.stderr | 12 ------ .../sync/libc_pthread_rwlock_write_wrong_owner.rs | 28 ------------- .../libc_pthread_rwlock_write_wrong_owner.stderr | 15 ------- src/tools/miri/tests/fail/tokio/sleep.rs | 14 ------- src/tools/miri/tests/fail/tokio/sleep.stderr | 15 ------- .../tests/fail/unsupported_incomplete_function.rs | 11 ----- .../fail/unsupported_incomplete_function.stderr | 14 ------- 193 files changed, 1571 insertions(+), 1565 deletions(-) create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/close_stdout.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/close_stdout.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/memchr_null.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/memchr_null.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/memcmp_null.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/memcmp_null.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/memcmp_zero.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/memcmp_zero.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/memcpy_zero.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/memcpy_zero.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/memrchr_null.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/memrchr_null.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/munmap.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/munmap.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/munmap_partial.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/munmap_partial.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr create mode 100644 src/tools/miri/tests/fail-dep/tokio/sleep.rs create mode 100644 src/tools/miri/tests/fail-dep/tokio/sleep.stderr create mode 100644 src/tools/miri/tests/fail-dep/unsupported_incomplete_function.rs create mode 100644 src/tools/miri/tests/fail-dep/unsupported_incomplete_function.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/close_stdout.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/close_stdout.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/isolated_stdin.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/isolated_stdin.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/read_from_stdout.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/read_from_stdout.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/write_to_stdin.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/write_to_stdin.stderr delete mode 100644 src/tools/miri/tests/fail/shims/memchr_null.rs delete mode 100644 src/tools/miri/tests/fail/shims/memchr_null.stderr delete mode 100644 src/tools/miri/tests/fail/shims/memcmp_null.rs delete mode 100644 src/tools/miri/tests/fail/shims/memcmp_null.stderr delete mode 100644 src/tools/miri/tests/fail/shims/memcmp_zero.rs delete mode 100644 src/tools/miri/tests/fail/shims/memcmp_zero.stderr delete mode 100644 src/tools/miri/tests/fail/shims/memcpy_zero.rs delete mode 100644 src/tools/miri/tests/fail/shims/memcpy_zero.stderr delete mode 100644 src/tools/miri/tests/fail/shims/memrchr_null.rs delete mode 100644 src/tools/miri/tests/fail/shims/memrchr_null.stderr delete mode 100644 src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.rs delete mode 100644 src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.stderr delete mode 100644 src/tools/miri/tests/fail/shims/mmap_use_after_munmap.rs delete mode 100644 src/tools/miri/tests/fail/shims/mmap_use_after_munmap.stderr delete mode 100644 src/tools/miri/tests/fail/shims/munmap.rs delete mode 100644 src/tools/miri/tests/fail/shims/munmap.stderr delete mode 100644 src/tools/miri/tests/fail/shims/munmap_partial.rs delete mode 100644 src/tools/miri/tests/fail/shims/munmap_partial.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr delete mode 100644 src/tools/miri/tests/fail/tokio/sleep.rs delete mode 100644 src/tools/miri/tests/fail/tokio/sleep.stderr delete mode 100644 src/tools/miri/tests/fail/unsupported_incomplete_function.rs delete mode 100644 src/tools/miri/tests/fail/unsupported_incomplete_function.stderr (limited to 'src/tools') diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index f3ea43c0413..d84f943a6f9 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -243,6 +243,12 @@ fn main() -> Result<()> { Mode::Fail { require_patterns: true, rustfix: false }, "tests/fail", &target, + WithoutDependencies, + )?; + ui( + Mode::Fail { require_patterns: true, rustfix: false }, + "tests/fail-dep", + &target, WithDependencies, )?; if cfg!(target_os = "linux") { diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.rs new file mode 100644 index 00000000000..7e6f490bb3d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.rs @@ -0,0 +1,19 @@ +//@ignore-target-windows: No libc on Windows +//@error-in-other-file: the main thread terminated without waiting for all remaining threads + +// Check that we terminate the program when the main thread terminates. + +use std::{mem, ptr}; + +extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { + loop {} +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.stderr new file mode 100644 index 00000000000..c5093c0e601 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.stderr @@ -0,0 +1,6 @@ +error: the main thread terminated without waiting for all remaining threads + +note: pass `-Zmiri-ignore-leaks` to disable this check + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.rs new file mode 100644 index 00000000000..e1d3704af7c --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.rs @@ -0,0 +1,22 @@ +//@ignore-target-windows: No libc on Windows + +//! The thread function must have exactly one argument. + +use std::{mem, ptr}; + +extern "C" fn thread_start() -> *mut libc::c_void { + panic!() //~ ERROR: callee has fewer arguments than expected +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + let thread_start: extern "C" fn() -> *mut libc::c_void = thread_start; + let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = + mem::transmute(thread_start); + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.stderr new file mode 100644 index 00000000000..c2de4afd68f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.stderr @@ -0,0 +1,14 @@ +error: Undefined Behavior: callee has fewer arguments than expected + --> $DIR/libc_pthread_create_too_few_args.rs:LL:CC + | +LL | panic!() + | ^^^^^^^^ callee has fewer arguments than expected + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `thread_start` at RUSTLIB/core/src/panic.rs:LL:CC + = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.rs new file mode 100644 index 00000000000..7408634db52 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.rs @@ -0,0 +1,22 @@ +//@ignore-target-windows: No libc on Windows + +//! The thread function must have exactly one argument. + +use std::{mem, ptr}; + +extern "C" fn thread_start(_null: *mut libc::c_void, _x: i32) -> *mut libc::c_void { + panic!() //~ ERROR: callee has more arguments than expected +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + let thread_start: extern "C" fn(*mut libc::c_void, i32) -> *mut libc::c_void = thread_start; + let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = + mem::transmute(thread_start); + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.stderr new file mode 100644 index 00000000000..85ae930d439 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.stderr @@ -0,0 +1,14 @@ +error: Undefined Behavior: callee has more arguments than expected + --> $DIR/libc_pthread_create_too_many_args.rs:LL:CC + | +LL | panic!() + | ^^^^^^^^ callee has more arguments than expected + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `thread_start` at RUSTLIB/core/src/panic.rs:LL:CC + = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.rs new file mode 100644 index 00000000000..0b810dc8c72 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.rs @@ -0,0 +1,20 @@ +//@ignore-target-windows: No libc on Windows + +// Joining a detached thread is undefined behavior. + +use std::{mem, ptr}; + +extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { + ptr::null_mut() +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + assert_eq!(libc::pthread_detach(native), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join a detached thread + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.stderr new file mode 100644 index 00000000000..763e0d3665d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to join a detached thread + --> $DIR/libc_pthread_join_detached.rs:LL:CC + | +LL | assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join a detached thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_join_detached.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.rs new file mode 100644 index 00000000000..04ca4bbb3f6 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.rs @@ -0,0 +1,20 @@ +//@ignore-target-windows: No libc on Windows + +// Joining an already joined thread is undefined behavior. + +use std::{mem, ptr}; + +extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { + ptr::null_mut() +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join an already joined thread + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.stderr new file mode 100644 index 00000000000..a3253e2ef93 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to join an already joined thread + --> $DIR/libc_pthread_join_joined.rs:LL:CC + | +LL | assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join an already joined thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_join_joined.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.rs new file mode 100644 index 00000000000..75765182163 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.rs @@ -0,0 +1,16 @@ +//@ignore-target-windows: No libc on Windows + +// Joining the main thread is undefined behavior. + +use std::{ptr, thread}; + +fn main() { + let thread_id: libc::pthread_t = unsafe { libc::pthread_self() }; + let handle = thread::spawn(move || { + unsafe { + assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join a detached thread + } + }); + thread::yield_now(); + handle.join().unwrap(); +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.stderr new file mode 100644 index 00000000000..09e14d46a96 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to join a detached thread + --> $DIR/libc_pthread_join_main.rs:LL:CC + | +LL | assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join a detached thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside closure at $DIR/libc_pthread_join_main.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs new file mode 100644 index 00000000000..966f416eeac --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs @@ -0,0 +1,29 @@ +//@ignore-target-windows: No libc on Windows + +// Joining the same thread from multiple threads is undefined behavior. + +use std::thread; +use std::{mem, ptr}; + +extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { + // Yield the thread several times so that other threads can join it. + thread::yield_now(); + thread::yield_now(); + ptr::null_mut() +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + let mut native_copy: libc::pthread_t = mem::zeroed(); + ptr::copy_nonoverlapping(&native, &mut native_copy, 1); + let handle = thread::spawn(move || { + assert_eq!(libc::pthread_join(native_copy, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join an already joined thread + }); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + handle.join().unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.stderr new file mode 100644 index 00000000000..db5d7bfd5da --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to join an already joined thread + --> $DIR/libc_pthread_join_multiple.rs:LL:CC + | +LL | ... assert_eq!(libc::pthread_join(native_copy, ptr::null_mut()), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join an already joined thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside closure at $DIR/libc_pthread_join_multiple.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.rs new file mode 100644 index 00000000000..0c25c690f37 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.rs @@ -0,0 +1,18 @@ +//@ignore-target-windows: No libc on Windows +// We are making scheduler assumptions here. +//@compile-flags: -Zmiri-preemption-rate=0 + +// Joining itself is undefined behavior. + +use std::{ptr, thread}; + +fn main() { + let handle = thread::spawn(|| { + unsafe { + let native: libc::pthread_t = libc::pthread_self(); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join itself + } + }); + thread::yield_now(); + handle.join().unwrap(); +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.stderr new file mode 100644 index 00000000000..8db4a83f9ce --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to join itself + --> $DIR/libc_pthread_join_self.rs:LL:CC + | +LL | assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join itself + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside closure at $DIR/libc_pthread_join_self.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs b/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs new file mode 100644 index 00000000000..4704cfed039 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs @@ -0,0 +1,29 @@ +//@ignore-target-windows: No libc on Windows + +//@compile-flags: -Zmiri-disable-abi-check + +//! Unwinding past the top frame of a stack is Undefined Behavior. + +#![feature(c_unwind)] + +use std::{mem, ptr}; + +extern "C-unwind" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { + //~^ ERROR: unwinding past the topmost frame of the stack + panic!() +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + // Cast to avoid inserting abort-on-unwind. + let thread_start: extern "C-unwind" fn(*mut libc::c_void) -> *mut libc::c_void = + thread_start; + let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = + mem::transmute(thread_start); + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr b/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr new file mode 100644 index 00000000000..fccd3fbbc9d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr @@ -0,0 +1,21 @@ +WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed. +If you have a use-case for it, please file an issue. +thread '' panicked at $DIR/unwind_top_of_stack.rs:LL:CC: +explicit panic +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: Undefined Behavior: unwinding past the topmost frame of the stack + --> $DIR/unwind_top_of_stack.rs:LL:CC + | +LL | / extern "C-unwind" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { +LL | | +LL | | panic!() +LL | | } + | |_^ unwinding past the topmost frame of the stack + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `thread_start` at $DIR/unwind_top_of_stack.rs:LL:CC + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.rs b/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.rs new file mode 100644 index 00000000000..09da8509af4 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.rs @@ -0,0 +1,10 @@ +//@ignore-target-windows: No libc on Windows +//@compile-flags: -Zmiri-disable-isolation + +// FIXME: standard handles cannot be closed (https://github.com/rust-lang/rust/issues/40032) + +fn main() { + unsafe { + libc::close(1); //~ ERROR: cannot close stdout + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.stderr b/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.stderr new file mode 100644 index 00000000000..02f1eee97fc --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: cannot close stdout + --> $DIR/close_stdout.rs:LL:CC + | +LL | libc::close(1); + | ^^^^^^^^^^^^^^ cannot close stdout + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + = note: BACKTRACE: + = note: inside `main` at $DIR/close_stdout.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.rs b/src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.rs new file mode 100644 index 00000000000..a45f805696d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() -> std::io::Result<()> { + let mut bytes = [0u8; 512]; + unsafe { + libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512); //~ ERROR: `read` from stdin not available when isolation is enabled + } + Ok(()) +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.stderr b/src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.stderr new file mode 100644 index 00000000000..ed826147e3b --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.stderr @@ -0,0 +1,15 @@ +error: unsupported operation: `read` from stdin not available when isolation is enabled + --> $DIR/isolated_stdin.rs:LL:CC + | +LL | libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `read` from stdin not available when isolation is enabled + | + = help: pass the flag `-Zmiri-disable-isolation` to disable isolation; + = help: or pass `-Zmiri-isolation-error=warn` to configure Miri to return an error code from isolated operations (if supported for that operation) and continue with a warning + = note: BACKTRACE: + = note: inside `main` at $DIR/isolated_stdin.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.rs b/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.rs new file mode 100644 index 00000000000..ba9f404d7c9 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.rs @@ -0,0 +1,11 @@ +//@ignore-target-windows: No libc on Windows +//@compile-flags: -Zmiri-disable-isolation + +fn main() { + test_mkstemp_immutable_arg(); +} + +fn test_mkstemp_immutable_arg() { + let s: *mut libc::c_char = b"fooXXXXXX\0" as *const _ as *mut _; + let _fd = unsafe { libc::mkstemp(s) }; //~ ERROR: Undefined Behavior: writing to alloc1 which is read-only +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.stderr b/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.stderr new file mode 100644 index 00000000000..35ff1926b06 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: writing to ALLOC which is read-only + --> $DIR/mkstemp_immutable_arg.rs:LL:CC + | +LL | let _fd = unsafe { libc::mkstemp(s) }; + | ^^^^^^^^^^^^^^^^ writing to ALLOC which is read-only + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `test_mkstemp_immutable_arg` at $DIR/mkstemp_immutable_arg.rs:LL:CC +note: inside `main` + --> $DIR/mkstemp_immutable_arg.rs:LL:CC + | +LL | test_mkstemp_immutable_arg(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.rs b/src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.rs new file mode 100644 index 00000000000..073fca4712e --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.rs @@ -0,0 +1,10 @@ +//@compile-flags: -Zmiri-disable-isolation +//@ignore-target-windows: No libc on Windows + +fn main() -> std::io::Result<()> { + let mut bytes = [0u8; 512]; + unsafe { + libc::read(1, bytes.as_mut_ptr() as *mut libc::c_void, 512); //~ ERROR: cannot read from stdout + } + Ok(()) +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.stderr b/src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.stderr new file mode 100644 index 00000000000..bcece7ad4e5 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: cannot read from stdout + --> $DIR/read_from_stdout.rs:LL:CC + | +LL | libc::read(1, bytes.as_mut_ptr() as *mut libc::c_void, 512); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot read from stdout + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + = note: BACKTRACE: + = note: inside `main` at $DIR/read_from_stdout.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.rs b/src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.rs new file mode 100644 index 00000000000..ae231d4be66 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.rs @@ -0,0 +1,12 @@ +//@ignore-target-windows: No libc on Windows +//@compile-flags: -Zmiri-disable-isolation + +fn main() { + test_file_open_missing_needed_mode(); +} + +fn test_file_open_missing_needed_mode() { + let name = b"missing_arg.txt\0"; + let name_ptr = name.as_ptr().cast::(); + let _fd = unsafe { libc::open(name_ptr, libc::O_CREAT) }; //~ ERROR: Undefined Behavior: incorrect number of arguments for `open` with `O_CREAT`: got 2, expected at least 3 +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.stderr b/src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.stderr new file mode 100644 index 00000000000..5a8e7352c76 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: incorrect number of arguments for `open` with `O_CREAT`: got 2, expected at least 3 + --> $DIR/unix_open_missing_required_mode.rs:LL:CC + | +LL | ...safe { libc::open(name_ptr, libc::O_CREAT) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of arguments for `open` with `O_CREAT`: got 2, expected at least 3 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `test_file_open_missing_needed_mode` at $DIR/unix_open_missing_required_mode.rs:LL:CC +note: inside `main` + --> $DIR/unix_open_missing_required_mode.rs:LL:CC + | +LL | test_file_open_missing_needed_mode(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.rs b/src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.rs new file mode 100644 index 00000000000..d039ad718d3 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() -> std::io::Result<()> { + let bytes = b"hello"; + unsafe { + libc::write(0, bytes.as_ptr() as *const libc::c_void, 5); //~ ERROR: cannot write to stdin + } + Ok(()) +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.stderr b/src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.stderr new file mode 100644 index 00000000000..d4a38e1ca96 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: cannot write to stdin + --> $DIR/write_to_stdin.rs:LL:CC + | +LL | libc::write(0, bytes.as_ptr() as *const libc::c_void, 5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot write to stdin + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + = note: BACKTRACE: + = note: inside `main` at $DIR/write_to_stdin.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/memchr_null.rs b/src/tools/miri/tests/fail-dep/shims/memchr_null.rs new file mode 100644 index 00000000000..6bc7af7e6bf --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memchr_null.rs @@ -0,0 +1,10 @@ +//@ignore-target-windows: No libc on Windows + +use std::ptr; + +// null is explicitly called out as UB in the C docs. +fn main() { + unsafe { + libc::memchr(ptr::null(), 0, 0); //~ERROR: dangling + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/memchr_null.stderr b/src/tools/miri/tests/fail-dep/shims/memchr_null.stderr new file mode 100644 index 00000000000..54b58f22c6c --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memchr_null.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + --> $DIR/memchr_null.rs:LL:CC + | +LL | libc::memchr(ptr::null(), 0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/memchr_null.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/memcmp_null.rs b/src/tools/miri/tests/fail-dep/shims/memcmp_null.rs new file mode 100644 index 00000000000..a4e0034c40b --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcmp_null.rs @@ -0,0 +1,10 @@ +//@ignore-target-windows: No libc on Windows + +use std::ptr; + +// null is explicitly called out as UB in the C docs. +fn main() { + unsafe { + libc::memcmp(ptr::null(), ptr::null(), 0); //~ERROR: dangling + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/memcmp_null.stderr b/src/tools/miri/tests/fail-dep/shims/memcmp_null.stderr new file mode 100644 index 00000000000..8b2882fc243 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcmp_null.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + --> $DIR/memcmp_null.rs:LL:CC + | +LL | libc::memcmp(ptr::null(), ptr::null(), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/memcmp_null.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/memcmp_zero.rs b/src/tools/miri/tests/fail-dep/shims/memcmp_zero.rs new file mode 100644 index 00000000000..f2ddc200563 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcmp_zero.rs @@ -0,0 +1,13 @@ +//@ignore-target-windows: No libc on Windows +//@compile-flags: -Zmiri-permissive-provenance + +// C says that passing "invalid" pointers is UB for all string functions. +// It is unclear whether `(int*)42` is "invalid", but there is no actually +// a `char` living at that address, so arguably it cannot be a valid pointer. +// Hence this is UB. +fn main() { + let ptr = 42 as *const u8; + unsafe { + libc::memcmp(ptr.cast(), ptr.cast(), 0); //~ERROR: dangling + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/memcmp_zero.stderr b/src/tools/miri/tests/fail-dep/shims/memcmp_zero.stderr new file mode 100644 index 00000000000..e21b9b06008 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcmp_zero.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance) + --> $DIR/memcmp_zero.rs:LL:CC + | +LL | libc::memcmp(ptr.cast(), ptr.cast(), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/memcmp_zero.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/memcpy_zero.rs b/src/tools/miri/tests/fail-dep/shims/memcpy_zero.rs new file mode 100644 index 00000000000..5283fea4cb9 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcpy_zero.rs @@ -0,0 +1,12 @@ +//@ignore-target-windows: No libc on Windows +//@compile-flags: -Zmiri-permissive-provenance +// C's memcpy is 0 bytes is UB for some pointers that are allowed in Rust's `copy_nonoverlapping`. + +fn main() { + let from = 42 as *const u8; + let to = 23 as *mut u8; + unsafe { + to.copy_from(from, 0); // this is fine + libc::memcpy(to.cast(), from.cast(), 0); //~ERROR: dangling + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/memcpy_zero.stderr b/src/tools/miri/tests/fail-dep/shims/memcpy_zero.stderr new file mode 100644 index 00000000000..7c1c3fe20c4 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcpy_zero.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: out-of-bounds pointer use: 0x17[noalloc] is a dangling pointer (it has no provenance) + --> $DIR/memcpy_zero.rs:LL:CC + | +LL | libc::memcpy(to.cast(), from.cast(), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x17[noalloc] is a dangling pointer (it has no provenance) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/memcpy_zero.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/memrchr_null.rs b/src/tools/miri/tests/fail-dep/shims/memrchr_null.rs new file mode 100644 index 00000000000..b6707d558d8 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memrchr_null.rs @@ -0,0 +1,11 @@ +//@ignore-target-windows: No libc on Windows +//@ignore-target-apple: No `memrchr` on some apple targets + +use std::ptr; + +// null is explicitly called out as UB in the C docs. +fn main() { + unsafe { + libc::memrchr(ptr::null(), 0, 0); //~ERROR: dangling + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/memrchr_null.stderr b/src/tools/miri/tests/fail-dep/shims/memrchr_null.stderr new file mode 100644 index 00000000000..cc11ba89f8f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memrchr_null.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + --> $DIR/memrchr_null.rs:LL:CC + | +LL | libc::memrchr(ptr::null(), 0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/memrchr_null.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.rs b/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.rs new file mode 100644 index 00000000000..70f7a6a7cef --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.rs @@ -0,0 +1,18 @@ +//@compile-flags: -Zmiri-disable-isolation +//@ignore-target-windows: No libc on Windows + +#![feature(rustc_private)] + +fn main() { + unsafe { + let ptr = libc::mmap( + std::ptr::null_mut(), + 4096, + libc::PROT_READ | libc::PROT_WRITE, + libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, + -1, + 0, + ); + libc::free(ptr); //~ ERROR: which is mmap memory, using C heap deallocation operation + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.stderr b/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.stderr new file mode 100644 index 00000000000..54e0cd5275d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: deallocating ALLOC, which is mmap memory, using C heap deallocation operation + --> $DIR/mmap_invalid_dealloc.rs:LL:CC + | +LL | libc::free(ptr); + | ^^^^^^^^^^^^^^^ deallocating ALLOC, which is mmap memory, using C heap deallocation operation + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/mmap_invalid_dealloc.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.rs b/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.rs new file mode 100644 index 00000000000..c97b013ba5a --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.rs @@ -0,0 +1,19 @@ +//@compile-flags: -Zmiri-disable-isolation +//@ignore-target-windows: No libc on Windows + +#![feature(rustc_private)] + +fn main() { + unsafe { + let ptr = libc::mmap( + std::ptr::null_mut(), + 4096, + libc::PROT_READ | libc::PROT_WRITE, + libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, + -1, + 0, + ); + libc::munmap(ptr, 4096); + let _x = *(ptr as *mut u8); //~ ERROR: has been freed + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.stderr b/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.stderr new file mode 100644 index 00000000000..44e122330bc --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.stderr @@ -0,0 +1,47 @@ +warning: integer-to-pointer cast + --> $DIR/mmap_use_after_munmap.rs:LL:CC + | +LL | libc::munmap(ptr, 4096); + | ^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast + | + = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, + = help: which means that Miri might miss pointer bugs in this program. + = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. + = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. + = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. + = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. + = note: BACKTRACE: + = note: inside `main` at $DIR/mmap_use_after_munmap.rs:LL:CC + +error: Undefined Behavior: dereferencing pointer failed: ALLOC has been freed, so this pointer is dangling + --> $DIR/mmap_use_after_munmap.rs:LL:CC + | +LL | let _x = *(ptr as *mut u8); + | ^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has been freed, so this pointer is dangling + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information +help: ALLOC was allocated here: + --> $DIR/mmap_use_after_munmap.rs:LL:CC + | +LL | let ptr = libc::mmap( + | ___________________^ +LL | | std::ptr::null_mut(), +LL | | 4096, +LL | | libc::PROT_READ | libc::PROT_WRITE, +... | +LL | | 0, +LL | | ); + | |_________^ +help: ALLOC was deallocated here: + --> $DIR/mmap_use_after_munmap.rs:LL:CC + | +LL | libc::munmap(ptr, 4096); + | ^^^^^^^^^^^^^^^^^^^^^^^ + = note: BACKTRACE (of the first span): + = note: inside `main` at $DIR/mmap_use_after_munmap.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/src/tools/miri/tests/fail-dep/shims/munmap.rs b/src/tools/miri/tests/fail-dep/shims/munmap.rs new file mode 100644 index 00000000000..453437a06cf --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/munmap.rs @@ -0,0 +1,22 @@ +//@compile-flags: -Zmiri-disable-isolation +//@ignore-target-windows: No libc on Windows + +#![feature(rustc_private)] +#![feature(strict_provenance)] + +use std::ptr; + +fn main() { + // Linux specifies that it is not an error if the specified range does not contain any pages. + // But we simply do not support such calls. This test checks that we report this as + // unsupported, not Undefined Behavior. + let res = unsafe { + libc::munmap( + //~^ ERROR: unsupported operation + // Some high address we surely have not allocated anything at + ptr::invalid_mut(1 << 30), + 4096, + ) + }; + assert_eq!(res, 0); +} diff --git a/src/tools/miri/tests/fail-dep/shims/munmap.stderr b/src/tools/miri/tests/fail-dep/shims/munmap.stderr new file mode 100644 index 00000000000..cb47769c063 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/munmap.stderr @@ -0,0 +1,39 @@ +warning: integer-to-pointer cast + --> $DIR/munmap.rs:LL:CC + | +LL | / libc::munmap( +LL | | +LL | | // Some high address we surely have not allocated anything at +LL | | ptr::invalid_mut(1 << 30), +LL | | 4096, +LL | | ) + | |_________^ integer-to-pointer cast + | + = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, + = help: which means that Miri might miss pointer bugs in this program. + = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. + = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. + = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. + = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. + = note: BACKTRACE: + = note: inside `main` at $DIR/munmap.rs:LL:CC + +error: unsupported operation: Miri only supports munmap on memory allocated directly by mmap + --> $DIR/munmap.rs:LL:CC + | +LL | / libc::munmap( +LL | | +LL | | // Some high address we surely have not allocated anything at +LL | | ptr::invalid_mut(1 << 30), +LL | | 4096, +LL | | ) + | |_________^ Miri only supports munmap on memory allocated directly by mmap + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + = note: BACKTRACE: + = note: inside `main` at $DIR/munmap.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/src/tools/miri/tests/fail-dep/shims/munmap_partial.rs b/src/tools/miri/tests/fail-dep/shims/munmap_partial.rs new file mode 100644 index 00000000000..938850ee286 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/munmap_partial.rs @@ -0,0 +1,18 @@ +//! Our mmap/munmap support is a thin wrapper over Interpcx::allocate_ptr. Since the underlying +//! layer has much more UB than munmap does, we need to be sure we throw an unsupported error here. +//@ignore-target-windows: No libc on Windows + +fn main() { + unsafe { + let ptr = libc::mmap( + std::ptr::null_mut(), + page_size::get() * 2, + libc::PROT_READ | libc::PROT_WRITE, + libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, + -1, + 0, + ); + libc::munmap(ptr, 1); + //~^ ERROR: unsupported operation + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/munmap_partial.stderr b/src/tools/miri/tests/fail-dep/shims/munmap_partial.stderr new file mode 100644 index 00000000000..9a084c50437 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/munmap_partial.stderr @@ -0,0 +1,29 @@ +warning: integer-to-pointer cast + --> $DIR/munmap_partial.rs:LL:CC + | +LL | libc::munmap(ptr, 1); + | ^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast + | + = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, + = help: which means that Miri might miss pointer bugs in this program. + = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. + = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. + = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. + = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. + = note: BACKTRACE: + = note: inside `main` at $DIR/munmap_partial.rs:LL:CC + +error: unsupported operation: Miri only supports munmap calls that exactly unmap a region previously returned by mmap + --> $DIR/munmap_partial.rs:LL:CC + | +LL | libc::munmap(ptr, 1); + | ^^^^^^^^^^^^^^^^^^^^ Miri only supports munmap calls that exactly unmap a region previously returned by mmap + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + = note: BACKTRACE: + = note: inside `main` at $DIR/munmap_partial.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.rs new file mode 100644 index 00000000000..94ca3496ed9 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.rs @@ -0,0 +1,20 @@ +//@ignore-target-windows: No libc on Windows + +/// Test that destroying a pthread_cond twice fails, even without a check for number validity + +fn main() { + unsafe { + use core::mem::MaybeUninit; + let mut attr = MaybeUninit::::uninit(); + libc::pthread_condattr_init(attr.as_mut_ptr()); + + let mut cond = MaybeUninit::::uninit(); + + libc::pthread_cond_init(cond.as_mut_ptr(), attr.as_ptr()); + + libc::pthread_cond_destroy(cond.as_mut_ptr()); + + libc::pthread_cond_destroy(cond.as_mut_ptr()); + //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.stderr new file mode 100644 index 00000000000..ecfedf75370 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/libc_pthread_cond_double_destroy.rs:LL:CC + | +LL | libc::pthread_cond_destroy(cond.as_mut_ptr()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_cond_double_destroy.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.rs new file mode 100644 index 00000000000..13e639a867d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.rs @@ -0,0 +1,17 @@ +//@ignore-target-windows: No libc on Windows + +/// Test that destroying a pthread_condattr twice fails, even without a check for number validity + +fn main() { + unsafe { + use core::mem::MaybeUninit; + let mut attr = MaybeUninit::::uninit(); + + libc::pthread_condattr_init(attr.as_mut_ptr()); + + libc::pthread_condattr_destroy(attr.as_mut_ptr()); + + libc::pthread_condattr_destroy(attr.as_mut_ptr()); + //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.stderr new file mode 100644 index 00000000000..f39d909adbd --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/libc_pthread_condattr_double_destroy.rs:LL:CC + | +LL | libc::pthread_condattr_destroy(attr.as_mut_ptr()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_condattr_double_destroy.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.rs new file mode 100644 index 00000000000..8b251073383 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.rs @@ -0,0 +1,12 @@ +//@ignore-target-windows: No libc on Windows +// +// Check that if we pass NULL attribute, then we get the default mutex type. + +fn main() { + unsafe { + let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); + assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, std::ptr::null() as *const _), 0); + assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); + libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: Undefined Behavior: trying to acquire already locked default mutex + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr new file mode 100644 index 00000000000..4a138e6f8a2 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to acquire already locked default mutex + --> $DIR/libc_pthread_mutex_NULL_deadlock.rs:LL:CC + | +LL | libc::pthread_mutex_lock(&mut mutex as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to acquire already locked default mutex + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_mutex_NULL_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.rs new file mode 100644 index 00000000000..6c3cb738e29 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct Mutex(UnsafeCell); + +unsafe impl Send for Mutex {} +unsafe impl Sync for Mutex {} + +fn new_lock() -> Arc { + Arc::new(Mutex(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_mutex_lock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_mutex_lock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.stderr new file mode 100644 index 00000000000..599655a8692 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.stderr @@ -0,0 +1,12 @@ +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_mutex_deadlock.rs:LL:CC + | +LL | assert_eq!(libc::pthread_mutex_lock(lock_copy.0.get() as *mut _), 0); + | ^ the evaluated program deadlocked + | + = note: inside closure at $DIR/libc_pthread_mutex_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.rs new file mode 100644 index 00000000000..f443768819f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.rs @@ -0,0 +1,13 @@ +//@ignore-target-windows: No libc on Windows +// +// Check that if we do not set the mutex type, it is the default. + +fn main() { + unsafe { + let mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); + let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); + assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); + assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); + libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: Undefined Behavior: trying to acquire already locked default mutex + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.stderr new file mode 100644 index 00000000000..8aea3f5c693 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to acquire already locked default mutex + --> $DIR/libc_pthread_mutex_default_deadlock.rs:LL:CC + | +LL | libc::pthread_mutex_lock(&mut mutex as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to acquire already locked default mutex + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_mutex_default_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.rs new file mode 100644 index 00000000000..ec3965c7574 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.rs @@ -0,0 +1,15 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + unsafe { + let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); + assert_eq!( + libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), + 0, + ); + let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); + assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); + assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); + libc::pthread_mutex_destroy(&mut mutex as *mut _); //~ ERROR: destroyed a locked mutex + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.stderr new file mode 100644 index 00000000000..a8ab948116e --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: destroyed a locked mutex + --> $DIR/libc_pthread_mutex_destroy_locked.rs:LL:CC + | +LL | libc::pthread_mutex_destroy(&mut mutex as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ destroyed a locked mutex + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_mutex_destroy_locked.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.rs new file mode 100644 index 00000000000..622c3eaeae3 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.rs @@ -0,0 +1,21 @@ +//@ignore-target-windows: No libc on Windows + +/// Test that destroying a pthread_mutex twice fails, even without a check for number validity + +fn main() { + unsafe { + use core::mem::MaybeUninit; + + let mut attr = MaybeUninit::::uninit(); + libc::pthread_mutexattr_init(attr.as_mut_ptr()); + + let mut mutex = MaybeUninit::::uninit(); + + libc::pthread_mutex_init(mutex.as_mut_ptr(), attr.as_ptr()); + + libc::pthread_mutex_destroy(mutex.as_mut_ptr()); + + libc::pthread_mutex_destroy(mutex.as_mut_ptr()); + //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.stderr new file mode 100644 index 00000000000..9620fdbd18b --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/libc_pthread_mutex_double_destroy.rs:LL:CC + | +LL | libc::pthread_mutex_destroy(mutex.as_mut_ptr()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_mutex_double_destroy.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.rs new file mode 100644 index 00000000000..5ea09fa5aac --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.rs @@ -0,0 +1,15 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + unsafe { + let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); + assert_eq!( + libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), + 0, + ); + let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); + assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); + assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); + libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: deadlock: the evaluated program deadlocked + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.stderr new file mode 100644 index 00000000000..b7877d3aa39 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.stderr @@ -0,0 +1,12 @@ +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_mutex_normal_deadlock.rs:LL:CC + | +LL | libc::pthread_mutex_lock(&mut mutex as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program deadlocked + | + = note: inside `main` at $DIR/libc_pthread_mutex_normal_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs new file mode 100644 index 00000000000..8ce7542edb8 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs @@ -0,0 +1,16 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + unsafe { + let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); + assert_eq!( + libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), + 0, + ); + let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); + assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); + assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); + assert_eq!(libc::pthread_mutex_unlock(&mut mutex as *mut _), 0); + libc::pthread_mutex_unlock(&mut mutex as *mut _); //~ ERROR: was not locked + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr new file mode 100644 index 00000000000..754137b85b9 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: unlocked a PTHREAD_MUTEX_NORMAL mutex that was not locked by the current thread + --> $DIR/libc_pthread_mutex_normal_unlock_unlocked.rs:LL:CC + | +LL | libc::pthread_mutex_unlock(&mut mutex as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked a PTHREAD_MUTEX_NORMAL mutex that was not locked by the current thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_mutex_normal_unlock_unlocked.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.rs new file mode 100644 index 00000000000..b56775252e4 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct Mutex(UnsafeCell); + +unsafe impl Send for Mutex {} +unsafe impl Sync for Mutex {} + +fn new_lock() -> Arc { + Arc::new(Mutex(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_mutex_lock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_mutex_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked a default mutex that was not locked by the current thread + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.stderr new file mode 100644 index 00000000000..aa81b06fc80 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: unlocked a default mutex that was not locked by the current thread + --> $DIR/libc_pthread_mutex_wrong_owner.rs:LL:CC + | +LL | ...t_eq!(libc::pthread_mutex_unlock(lock_copy.0.get() as *mut _), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked a default mutex that was not locked by the current thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside closure at $DIR/libc_pthread_mutex_wrong_owner.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.rs new file mode 100644 index 00000000000..474a277516d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.rs @@ -0,0 +1,17 @@ +//@ignore-target-windows: No libc on Windows + +/// Test that destroying a pthread_mutexattr twice fails, even without a check for number validity + +fn main() { + unsafe { + use core::mem::MaybeUninit; + let mut attr = MaybeUninit::::uninit(); + + libc::pthread_mutexattr_init(attr.as_mut_ptr()); + + libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); + + libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); + //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.stderr new file mode 100644 index 00000000000..82949047d2a --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/libc_pthread_mutexattr_double_destroy.rs:LL:CC + | +LL | libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_mutexattr_double_destroy.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs new file mode 100644 index 00000000000..603580ff58a --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0); + libc::pthread_rwlock_destroy(rw.get()); //~ ERROR: destroyed a locked rwlock + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr new file mode 100644 index 00000000000..be73e7f1e2a --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: destroyed a locked rwlock + --> $DIR/libc_pthread_rwlock_destroy_read_locked.rs:LL:CC + | +LL | libc::pthread_rwlock_destroy(rw.get()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ destroyed a locked rwlock + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_rwlock_destroy_read_locked.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs new file mode 100644 index 00000000000..ae44f22d146 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); + libc::pthread_rwlock_destroy(rw.get()); //~ ERROR: destroyed a locked rwlock + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr new file mode 100644 index 00000000000..bc2713a5ffb --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: destroyed a locked rwlock + --> $DIR/libc_pthread_rwlock_destroy_write_locked.rs:LL:CC + | +LL | libc::pthread_rwlock_destroy(rw.get()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ destroyed a locked rwlock + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_rwlock_destroy_write_locked.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.rs new file mode 100644 index 00000000000..800986f7506 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.rs @@ -0,0 +1,14 @@ +//@ignore-target-windows: No libc on Windows + +/// Test that destroying a pthread_rwlock twice fails, even without a check for number validity + +fn main() { + unsafe { + let mut lock = libc::PTHREAD_RWLOCK_INITIALIZER; + + libc::pthread_rwlock_destroy(&mut lock); + + libc::pthread_rwlock_destroy(&mut lock); + //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.stderr new file mode 100644 index 00000000000..5004f84358d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/libc_pthread_rwlock_double_destroy.rs:LL:CC + | +LL | libc::pthread_rwlock_destroy(&mut lock); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_rwlock_double_destroy.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs new file mode 100644 index 00000000000..782c95b6d2e --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0); + libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr new file mode 100644 index 00000000000..075c8f0ef52 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr @@ -0,0 +1,12 @@ +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_rwlock_read_write_deadlock_single_thread.rs:LL:CC + | +LL | libc::pthread_rwlock_wrlock(rw.get()); + | ^ the evaluated program deadlocked + | + = note: inside `main` at $DIR/libc_pthread_rwlock_read_write_deadlock_single_thread.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs new file mode 100644 index 00000000000..1b498ad8fcd --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct RwLock(UnsafeCell); + +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} + +fn new_lock() -> Arc { + Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_rwlock_rdlock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked an rwlock that was not locked by the active thread + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr new file mode 100644 index 00000000000..7dfa27b43d0 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: unlocked an rwlock that was not locked by the active thread + --> $DIR/libc_pthread_rwlock_read_wrong_owner.rs:LL:CC + | +LL | ... assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked an rwlock that was not locked by the active thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside closure at $DIR/libc_pthread_rwlock_read_wrong_owner.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs new file mode 100644 index 00000000000..05f7e7a06c5 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs @@ -0,0 +1,8 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + libc::pthread_rwlock_unlock(rw.get()); //~ ERROR: was not locked + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr new file mode 100644 index 00000000000..1c25ac2c048 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: unlocked an rwlock that was not locked by the active thread + --> $DIR/libc_pthread_rwlock_unlock_unlocked.rs:LL:CC + | +LL | libc::pthread_rwlock_unlock(rw.get()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked an rwlock that was not locked by the active thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/libc_pthread_rwlock_unlock_unlocked.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs new file mode 100644 index 00000000000..201844615e1 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct RwLock(UnsafeCell); + +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} + +fn new_lock() -> Arc { + Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_rwlock_rdlock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr new file mode 100644 index 00000000000..333fb1afb91 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr @@ -0,0 +1,12 @@ +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_rwlock_write_read_deadlock.rs:LL:CC + | +LL | assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); + | ^ the evaluated program deadlocked + | + = note: inside closure at $DIR/libc_pthread_rwlock_write_read_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs new file mode 100644 index 00000000000..538f14ef89f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); + libc::pthread_rwlock_rdlock(rw.get()); //~ ERROR: deadlock + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr new file mode 100644 index 00000000000..caab19a782f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr @@ -0,0 +1,12 @@ +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_rwlock_write_read_deadlock_single_thread.rs:LL:CC + | +LL | libc::pthread_rwlock_rdlock(rw.get()); + | ^ the evaluated program deadlocked + | + = note: inside `main` at $DIR/libc_pthread_rwlock_write_read_deadlock_single_thread.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs new file mode 100644 index 00000000000..b1d7e0492e5 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct RwLock(UnsafeCell); + +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} + +fn new_lock() -> Arc { + Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_rwlock_wrlock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr new file mode 100644 index 00000000000..93bede54fcf --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr @@ -0,0 +1,12 @@ +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_rwlock_write_write_deadlock.rs:LL:CC + | +LL | assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); + | ^ the evaluated program deadlocked + | + = note: inside closure at $DIR/libc_pthread_rwlock_write_write_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs new file mode 100644 index 00000000000..2c963d36510 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); + libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr new file mode 100644 index 00000000000..30f5f447c71 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr @@ -0,0 +1,12 @@ +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_rwlock_write_write_deadlock_single_thread.rs:LL:CC + | +LL | libc::pthread_rwlock_wrlock(rw.get()); + | ^ the evaluated program deadlocked + | + = note: inside `main` at $DIR/libc_pthread_rwlock_write_write_deadlock_single_thread.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs new file mode 100644 index 00000000000..dd099474d8f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct RwLock(UnsafeCell); + +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} + +fn new_lock() -> Arc { + Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_rwlock_wrlock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked an rwlock that was not locked by the active thread + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr new file mode 100644 index 00000000000..5bf402c775a --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: unlocked an rwlock that was not locked by the active thread + --> $DIR/libc_pthread_rwlock_write_wrong_owner.rs:LL:CC + | +LL | ... assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked an rwlock that was not locked by the active thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside closure at $DIR/libc_pthread_rwlock_write_wrong_owner.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/tokio/sleep.rs b/src/tools/miri/tests/fail-dep/tokio/sleep.rs new file mode 100644 index 00000000000..d96d778e6ca --- /dev/null +++ b/src/tools/miri/tests/fail-dep/tokio/sleep.rs @@ -0,0 +1,14 @@ +//@compile-flags: -Zmiri-permissive-provenance -Zmiri-backtrace=full +//@only-target-x86_64-unknown-linux: support for tokio only on linux and x86 +//@error-in-other-file: returning ready events from epoll_wait is not yet implemented +//@normalize-stderr-test: " += note:.*\n" -> "" + +use tokio::time::{sleep, Duration, Instant}; + +#[tokio::main] +async fn main() { + let start = Instant::now(); + sleep(Duration::from_secs(1)).await; + let time_elapsed = &start.elapsed().as_millis(); + assert!((1000..1100).contains(time_elapsed), "{}", time_elapsed); +} diff --git a/src/tools/miri/tests/fail-dep/tokio/sleep.stderr b/src/tools/miri/tests/fail-dep/tokio/sleep.stderr new file mode 100644 index 00000000000..ac2a984ed51 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/tokio/sleep.stderr @@ -0,0 +1,15 @@ +error: unsupported operation: returning ready events from epoll_wait is not yet implemented + --> CARGO_REGISTRY/.../epoll.rs:LL:CC + | +LL | / syscall!(epoll_wait( +LL | | self.ep, +LL | | events.as_mut_ptr(), +LL | | events.capacity() as i32, +LL | | timeout, +LL | | )) + | |__________^ returning ready events from epoll_wait is not yet implemented + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.rs b/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.rs new file mode 100644 index 00000000000..6ef842c9ccb --- /dev/null +++ b/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.rs @@ -0,0 +1,11 @@ +//! `signal()` is special on Linux and macOS that it's only supported within libstd. +//! The implementation is not complete enough to permit user code to call it. +//@ignore-target-windows: No libc on Windows +//@normalize-stderr-test: "OS `.*`" -> "$$OS" + +fn main() { + unsafe { + libc::signal(libc::SIGPIPE, libc::SIG_IGN); + //~^ ERROR: unsupported operation: can't call foreign function `signal` + } +} diff --git a/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.stderr b/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.stderr new file mode 100644 index 00000000000..ec2bba61172 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: can't call foreign function `signal` on $OS + --> $DIR/unsupported_incomplete_function.rs:LL:CC + | +LL | libc::signal(libc::SIGPIPE, libc::SIG_IGN); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `signal` on $OS + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + = note: BACKTRACE: + = note: inside `main` at $DIR/unsupported_incomplete_function.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.rs deleted file mode 100644 index 7e6f490bb3d..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@error-in-other-file: the main thread terminated without waiting for all remaining threads - -// Check that we terminate the program when the main thread terminates. - -use std::{mem, ptr}; - -extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { - loop {} -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.stderr deleted file mode 100644 index c5093c0e601..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.stderr +++ /dev/null @@ -1,6 +0,0 @@ -error: the main thread terminated without waiting for all remaining threads - -note: pass `-Zmiri-ignore-leaks` to disable this check - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.rs deleted file mode 100644 index e1d3704af7c..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -//! The thread function must have exactly one argument. - -use std::{mem, ptr}; - -extern "C" fn thread_start() -> *mut libc::c_void { - panic!() //~ ERROR: callee has fewer arguments than expected -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - let thread_start: extern "C" fn() -> *mut libc::c_void = thread_start; - let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = - mem::transmute(thread_start); - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.stderr deleted file mode 100644 index c2de4afd68f..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: Undefined Behavior: callee has fewer arguments than expected - --> $DIR/libc_pthread_create_too_few_args.rs:LL:CC - | -LL | panic!() - | ^^^^^^^^ callee has fewer arguments than expected - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `thread_start` at RUSTLIB/core/src/panic.rs:LL:CC - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.rs deleted file mode 100644 index 7408634db52..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -//! The thread function must have exactly one argument. - -use std::{mem, ptr}; - -extern "C" fn thread_start(_null: *mut libc::c_void, _x: i32) -> *mut libc::c_void { - panic!() //~ ERROR: callee has more arguments than expected -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - let thread_start: extern "C" fn(*mut libc::c_void, i32) -> *mut libc::c_void = thread_start; - let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = - mem::transmute(thread_start); - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.stderr deleted file mode 100644 index 85ae930d439..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: Undefined Behavior: callee has more arguments than expected - --> $DIR/libc_pthread_create_too_many_args.rs:LL:CC - | -LL | panic!() - | ^^^^^^^^ callee has more arguments than expected - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `thread_start` at RUSTLIB/core/src/panic.rs:LL:CC - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.rs deleted file mode 100644 index 0b810dc8c72..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -// Joining a detached thread is undefined behavior. - -use std::{mem, ptr}; - -extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { - ptr::null_mut() -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - assert_eq!(libc::pthread_detach(native), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join a detached thread - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.stderr deleted file mode 100644 index 763e0d3665d..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: trying to join a detached thread - --> $DIR/libc_pthread_join_detached.rs:LL:CC - | -LL | assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join a detached thread - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_join_detached.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.rs deleted file mode 100644 index 04ca4bbb3f6..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -// Joining an already joined thread is undefined behavior. - -use std::{mem, ptr}; - -extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { - ptr::null_mut() -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join an already joined thread - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.stderr deleted file mode 100644 index a3253e2ef93..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: trying to join an already joined thread - --> $DIR/libc_pthread_join_joined.rs:LL:CC - | -LL | assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join an already joined thread - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_join_joined.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.rs deleted file mode 100644 index 75765182163..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -// Joining the main thread is undefined behavior. - -use std::{ptr, thread}; - -fn main() { - let thread_id: libc::pthread_t = unsafe { libc::pthread_self() }; - let handle = thread::spawn(move || { - unsafe { - assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join a detached thread - } - }); - thread::yield_now(); - handle.join().unwrap(); -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.stderr deleted file mode 100644 index 09e14d46a96..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: trying to join a detached thread - --> $DIR/libc_pthread_join_main.rs:LL:CC - | -LL | assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join a detached thread - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside closure at $DIR/libc_pthread_join_main.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.rs deleted file mode 100644 index 966f416eeac..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.rs +++ /dev/null @@ -1,29 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -// Joining the same thread from multiple threads is undefined behavior. - -use std::thread; -use std::{mem, ptr}; - -extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { - // Yield the thread several times so that other threads can join it. - thread::yield_now(); - thread::yield_now(); - ptr::null_mut() -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - let mut native_copy: libc::pthread_t = mem::zeroed(); - ptr::copy_nonoverlapping(&native, &mut native_copy, 1); - let handle = thread::spawn(move || { - assert_eq!(libc::pthread_join(native_copy, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join an already joined thread - }); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - handle.join().unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.stderr deleted file mode 100644 index db5d7bfd5da..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: trying to join an already joined thread - --> $DIR/libc_pthread_join_multiple.rs:LL:CC - | -LL | ... assert_eq!(libc::pthread_join(native_copy, ptr::null_mut()), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join an already joined thread - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside closure at $DIR/libc_pthread_join_multiple.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.rs deleted file mode 100644 index 0c25c690f37..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ignore-target-windows: No libc on Windows -// We are making scheduler assumptions here. -//@compile-flags: -Zmiri-preemption-rate=0 - -// Joining itself is undefined behavior. - -use std::{ptr, thread}; - -fn main() { - let handle = thread::spawn(|| { - unsafe { - let native: libc::pthread_t = libc::pthread_self(); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join itself - } - }); - thread::yield_now(); - handle.join().unwrap(); -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.stderr deleted file mode 100644 index 8db4a83f9ce..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: trying to join itself - --> $DIR/libc_pthread_join_self.rs:LL:CC - | -LL | assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join itself - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside closure at $DIR/libc_pthread_join_self.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.rs b/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.rs deleted file mode 100644 index 4704cfed039..00000000000 --- a/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.rs +++ /dev/null @@ -1,29 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -//@compile-flags: -Zmiri-disable-abi-check - -//! Unwinding past the top frame of a stack is Undefined Behavior. - -#![feature(c_unwind)] - -use std::{mem, ptr}; - -extern "C-unwind" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { - //~^ ERROR: unwinding past the topmost frame of the stack - panic!() -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - // Cast to avoid inserting abort-on-unwind. - let thread_start: extern "C-unwind" fn(*mut libc::c_void) -> *mut libc::c_void = - thread_start; - let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = - mem::transmute(thread_start); - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - } -} diff --git a/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.stderr b/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.stderr deleted file mode 100644 index fccd3fbbc9d..00000000000 --- a/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.stderr +++ /dev/null @@ -1,21 +0,0 @@ -WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed. -If you have a use-case for it, please file an issue. -thread '' panicked at $DIR/unwind_top_of_stack.rs:LL:CC: -explicit panic -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -error: Undefined Behavior: unwinding past the topmost frame of the stack - --> $DIR/unwind_top_of_stack.rs:LL:CC - | -LL | / extern "C-unwind" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { -LL | | -LL | | panic!() -LL | | } - | |_^ unwinding past the topmost frame of the stack - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `thread_start` at $DIR/unwind_top_of_stack.rs:LL:CC - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/fs/close_stdout.rs b/src/tools/miri/tests/fail/shims/fs/close_stdout.rs deleted file mode 100644 index 09da8509af4..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/close_stdout.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@compile-flags: -Zmiri-disable-isolation - -// FIXME: standard handles cannot be closed (https://github.com/rust-lang/rust/issues/40032) - -fn main() { - unsafe { - libc::close(1); //~ ERROR: cannot close stdout - } -} diff --git a/src/tools/miri/tests/fail/shims/fs/close_stdout.stderr b/src/tools/miri/tests/fail/shims/fs/close_stdout.stderr deleted file mode 100644 index 02f1eee97fc..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/close_stdout.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unsupported operation: cannot close stdout - --> $DIR/close_stdout.rs:LL:CC - | -LL | libc::close(1); - | ^^^^^^^^^^^^^^ cannot close stdout - | - = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support - = note: BACKTRACE: - = note: inside `main` at $DIR/close_stdout.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/fs/isolated_stdin.rs b/src/tools/miri/tests/fail/shims/fs/isolated_stdin.rs deleted file mode 100644 index a45f805696d..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/isolated_stdin.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() -> std::io::Result<()> { - let mut bytes = [0u8; 512]; - unsafe { - libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512); //~ ERROR: `read` from stdin not available when isolation is enabled - } - Ok(()) -} diff --git a/src/tools/miri/tests/fail/shims/fs/isolated_stdin.stderr b/src/tools/miri/tests/fail/shims/fs/isolated_stdin.stderr deleted file mode 100644 index ed826147e3b..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/isolated_stdin.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: unsupported operation: `read` from stdin not available when isolation is enabled - --> $DIR/isolated_stdin.rs:LL:CC - | -LL | libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `read` from stdin not available when isolation is enabled - | - = help: pass the flag `-Zmiri-disable-isolation` to disable isolation; - = help: or pass `-Zmiri-isolation-error=warn` to configure Miri to return an error code from isolated operations (if supported for that operation) and continue with a warning - = note: BACKTRACE: - = note: inside `main` at $DIR/isolated_stdin.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.rs b/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.rs deleted file mode 100644 index ba9f404d7c9..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@compile-flags: -Zmiri-disable-isolation - -fn main() { - test_mkstemp_immutable_arg(); -} - -fn test_mkstemp_immutable_arg() { - let s: *mut libc::c_char = b"fooXXXXXX\0" as *const _ as *mut _; - let _fd = unsafe { libc::mkstemp(s) }; //~ ERROR: Undefined Behavior: writing to alloc1 which is read-only -} diff --git a/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.stderr b/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.stderr deleted file mode 100644 index 35ff1926b06..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: Undefined Behavior: writing to ALLOC which is read-only - --> $DIR/mkstemp_immutable_arg.rs:LL:CC - | -LL | let _fd = unsafe { libc::mkstemp(s) }; - | ^^^^^^^^^^^^^^^^ writing to ALLOC which is read-only - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `test_mkstemp_immutable_arg` at $DIR/mkstemp_immutable_arg.rs:LL:CC -note: inside `main` - --> $DIR/mkstemp_immutable_arg.rs:LL:CC - | -LL | test_mkstemp_immutable_arg(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/fs/read_from_stdout.rs b/src/tools/miri/tests/fail/shims/fs/read_from_stdout.rs deleted file mode 100644 index 073fca4712e..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/read_from_stdout.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@compile-flags: -Zmiri-disable-isolation -//@ignore-target-windows: No libc on Windows - -fn main() -> std::io::Result<()> { - let mut bytes = [0u8; 512]; - unsafe { - libc::read(1, bytes.as_mut_ptr() as *mut libc::c_void, 512); //~ ERROR: cannot read from stdout - } - Ok(()) -} diff --git a/src/tools/miri/tests/fail/shims/fs/read_from_stdout.stderr b/src/tools/miri/tests/fail/shims/fs/read_from_stdout.stderr deleted file mode 100644 index bcece7ad4e5..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/read_from_stdout.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unsupported operation: cannot read from stdout - --> $DIR/read_from_stdout.rs:LL:CC - | -LL | libc::read(1, bytes.as_mut_ptr() as *mut libc::c_void, 512); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot read from stdout - | - = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support - = note: BACKTRACE: - = note: inside `main` at $DIR/read_from_stdout.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.rs b/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.rs deleted file mode 100644 index ae231d4be66..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@compile-flags: -Zmiri-disable-isolation - -fn main() { - test_file_open_missing_needed_mode(); -} - -fn test_file_open_missing_needed_mode() { - let name = b"missing_arg.txt\0"; - let name_ptr = name.as_ptr().cast::(); - let _fd = unsafe { libc::open(name_ptr, libc::O_CREAT) }; //~ ERROR: Undefined Behavior: incorrect number of arguments for `open` with `O_CREAT`: got 2, expected at least 3 -} diff --git a/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.stderr b/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.stderr deleted file mode 100644 index 5a8e7352c76..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: Undefined Behavior: incorrect number of arguments for `open` with `O_CREAT`: got 2, expected at least 3 - --> $DIR/unix_open_missing_required_mode.rs:LL:CC - | -LL | ...safe { libc::open(name_ptr, libc::O_CREAT) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of arguments for `open` with `O_CREAT`: got 2, expected at least 3 - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `test_file_open_missing_needed_mode` at $DIR/unix_open_missing_required_mode.rs:LL:CC -note: inside `main` - --> $DIR/unix_open_missing_required_mode.rs:LL:CC - | -LL | test_file_open_missing_needed_mode(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/fs/write_to_stdin.rs b/src/tools/miri/tests/fail/shims/fs/write_to_stdin.rs deleted file mode 100644 index d039ad718d3..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/write_to_stdin.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() -> std::io::Result<()> { - let bytes = b"hello"; - unsafe { - libc::write(0, bytes.as_ptr() as *const libc::c_void, 5); //~ ERROR: cannot write to stdin - } - Ok(()) -} diff --git a/src/tools/miri/tests/fail/shims/fs/write_to_stdin.stderr b/src/tools/miri/tests/fail/shims/fs/write_to_stdin.stderr deleted file mode 100644 index d4a38e1ca96..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/write_to_stdin.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unsupported operation: cannot write to stdin - --> $DIR/write_to_stdin.rs:LL:CC - | -LL | libc::write(0, bytes.as_ptr() as *const libc::c_void, 5); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot write to stdin - | - = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support - = note: BACKTRACE: - = note: inside `main` at $DIR/write_to_stdin.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/memchr_null.rs b/src/tools/miri/tests/fail/shims/memchr_null.rs deleted file mode 100644 index 6bc7af7e6bf..00000000000 --- a/src/tools/miri/tests/fail/shims/memchr_null.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::ptr; - -// null is explicitly called out as UB in the C docs. -fn main() { - unsafe { - libc::memchr(ptr::null(), 0, 0); //~ERROR: dangling - } -} diff --git a/src/tools/miri/tests/fail/shims/memchr_null.stderr b/src/tools/miri/tests/fail/shims/memchr_null.stderr deleted file mode 100644 index 54b58f22c6c..00000000000 --- a/src/tools/miri/tests/fail/shims/memchr_null.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - --> $DIR/memchr_null.rs:LL:CC - | -LL | libc::memchr(ptr::null(), 0, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/memchr_null.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/memcmp_null.rs b/src/tools/miri/tests/fail/shims/memcmp_null.rs deleted file mode 100644 index a4e0034c40b..00000000000 --- a/src/tools/miri/tests/fail/shims/memcmp_null.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::ptr; - -// null is explicitly called out as UB in the C docs. -fn main() { - unsafe { - libc::memcmp(ptr::null(), ptr::null(), 0); //~ERROR: dangling - } -} diff --git a/src/tools/miri/tests/fail/shims/memcmp_null.stderr b/src/tools/miri/tests/fail/shims/memcmp_null.stderr deleted file mode 100644 index 8b2882fc243..00000000000 --- a/src/tools/miri/tests/fail/shims/memcmp_null.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - --> $DIR/memcmp_null.rs:LL:CC - | -LL | libc::memcmp(ptr::null(), ptr::null(), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/memcmp_null.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/memcmp_zero.rs b/src/tools/miri/tests/fail/shims/memcmp_zero.rs deleted file mode 100644 index f2ddc200563..00000000000 --- a/src/tools/miri/tests/fail/shims/memcmp_zero.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@compile-flags: -Zmiri-permissive-provenance - -// C says that passing "invalid" pointers is UB for all string functions. -// It is unclear whether `(int*)42` is "invalid", but there is no actually -// a `char` living at that address, so arguably it cannot be a valid pointer. -// Hence this is UB. -fn main() { - let ptr = 42 as *const u8; - unsafe { - libc::memcmp(ptr.cast(), ptr.cast(), 0); //~ERROR: dangling - } -} diff --git a/src/tools/miri/tests/fail/shims/memcmp_zero.stderr b/src/tools/miri/tests/fail/shims/memcmp_zero.stderr deleted file mode 100644 index e21b9b06008..00000000000 --- a/src/tools/miri/tests/fail/shims/memcmp_zero.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance) - --> $DIR/memcmp_zero.rs:LL:CC - | -LL | libc::memcmp(ptr.cast(), ptr.cast(), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance) - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/memcmp_zero.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/memcpy_zero.rs b/src/tools/miri/tests/fail/shims/memcpy_zero.rs deleted file mode 100644 index 5283fea4cb9..00000000000 --- a/src/tools/miri/tests/fail/shims/memcpy_zero.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@compile-flags: -Zmiri-permissive-provenance -// C's memcpy is 0 bytes is UB for some pointers that are allowed in Rust's `copy_nonoverlapping`. - -fn main() { - let from = 42 as *const u8; - let to = 23 as *mut u8; - unsafe { - to.copy_from(from, 0); // this is fine - libc::memcpy(to.cast(), from.cast(), 0); //~ERROR: dangling - } -} diff --git a/src/tools/miri/tests/fail/shims/memcpy_zero.stderr b/src/tools/miri/tests/fail/shims/memcpy_zero.stderr deleted file mode 100644 index 7c1c3fe20c4..00000000000 --- a/src/tools/miri/tests/fail/shims/memcpy_zero.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: out-of-bounds pointer use: 0x17[noalloc] is a dangling pointer (it has no provenance) - --> $DIR/memcpy_zero.rs:LL:CC - | -LL | libc::memcpy(to.cast(), from.cast(), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x17[noalloc] is a dangling pointer (it has no provenance) - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/memcpy_zero.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/memrchr_null.rs b/src/tools/miri/tests/fail/shims/memrchr_null.rs deleted file mode 100644 index b6707d558d8..00000000000 --- a/src/tools/miri/tests/fail/shims/memrchr_null.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@ignore-target-apple: No `memrchr` on some apple targets - -use std::ptr; - -// null is explicitly called out as UB in the C docs. -fn main() { - unsafe { - libc::memrchr(ptr::null(), 0, 0); //~ERROR: dangling - } -} diff --git a/src/tools/miri/tests/fail/shims/memrchr_null.stderr b/src/tools/miri/tests/fail/shims/memrchr_null.stderr deleted file mode 100644 index cc11ba89f8f..00000000000 --- a/src/tools/miri/tests/fail/shims/memrchr_null.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - --> $DIR/memrchr_null.rs:LL:CC - | -LL | libc::memrchr(ptr::null(), 0, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/memrchr_null.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.rs b/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.rs deleted file mode 100644 index 70f7a6a7cef..00000000000 --- a/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@compile-flags: -Zmiri-disable-isolation -//@ignore-target-windows: No libc on Windows - -#![feature(rustc_private)] - -fn main() { - unsafe { - let ptr = libc::mmap( - std::ptr::null_mut(), - 4096, - libc::PROT_READ | libc::PROT_WRITE, - libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, - -1, - 0, - ); - libc::free(ptr); //~ ERROR: which is mmap memory, using C heap deallocation operation - } -} diff --git a/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.stderr b/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.stderr deleted file mode 100644 index 54e0cd5275d..00000000000 --- a/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: deallocating ALLOC, which is mmap memory, using C heap deallocation operation - --> $DIR/mmap_invalid_dealloc.rs:LL:CC - | -LL | libc::free(ptr); - | ^^^^^^^^^^^^^^^ deallocating ALLOC, which is mmap memory, using C heap deallocation operation - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/mmap_invalid_dealloc.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.rs b/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.rs deleted file mode 100644 index c97b013ba5a..00000000000 --- a/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@compile-flags: -Zmiri-disable-isolation -//@ignore-target-windows: No libc on Windows - -#![feature(rustc_private)] - -fn main() { - unsafe { - let ptr = libc::mmap( - std::ptr::null_mut(), - 4096, - libc::PROT_READ | libc::PROT_WRITE, - libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, - -1, - 0, - ); - libc::munmap(ptr, 4096); - let _x = *(ptr as *mut u8); //~ ERROR: has been freed - } -} diff --git a/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.stderr b/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.stderr deleted file mode 100644 index 44e122330bc..00000000000 --- a/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.stderr +++ /dev/null @@ -1,47 +0,0 @@ -warning: integer-to-pointer cast - --> $DIR/mmap_use_after_munmap.rs:LL:CC - | -LL | libc::munmap(ptr, 4096); - | ^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast - | - = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, - = help: which means that Miri might miss pointer bugs in this program. - = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. - = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. - = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. - = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. - = note: BACKTRACE: - = note: inside `main` at $DIR/mmap_use_after_munmap.rs:LL:CC - -error: Undefined Behavior: dereferencing pointer failed: ALLOC has been freed, so this pointer is dangling - --> $DIR/mmap_use_after_munmap.rs:LL:CC - | -LL | let _x = *(ptr as *mut u8); - | ^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has been freed, so this pointer is dangling - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information -help: ALLOC was allocated here: - --> $DIR/mmap_use_after_munmap.rs:LL:CC - | -LL | let ptr = libc::mmap( - | ___________________^ -LL | | std::ptr::null_mut(), -LL | | 4096, -LL | | libc::PROT_READ | libc::PROT_WRITE, -... | -LL | | 0, -LL | | ); - | |_________^ -help: ALLOC was deallocated here: - --> $DIR/mmap_use_after_munmap.rs:LL:CC - | -LL | libc::munmap(ptr, 4096); - | ^^^^^^^^^^^^^^^^^^^^^^^ - = note: BACKTRACE (of the first span): - = note: inside `main` at $DIR/mmap_use_after_munmap.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error; 1 warning emitted - diff --git a/src/tools/miri/tests/fail/shims/munmap.rs b/src/tools/miri/tests/fail/shims/munmap.rs deleted file mode 100644 index 453437a06cf..00000000000 --- a/src/tools/miri/tests/fail/shims/munmap.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@compile-flags: -Zmiri-disable-isolation -//@ignore-target-windows: No libc on Windows - -#![feature(rustc_private)] -#![feature(strict_provenance)] - -use std::ptr; - -fn main() { - // Linux specifies that it is not an error if the specified range does not contain any pages. - // But we simply do not support such calls. This test checks that we report this as - // unsupported, not Undefined Behavior. - let res = unsafe { - libc::munmap( - //~^ ERROR: unsupported operation - // Some high address we surely have not allocated anything at - ptr::invalid_mut(1 << 30), - 4096, - ) - }; - assert_eq!(res, 0); -} diff --git a/src/tools/miri/tests/fail/shims/munmap.stderr b/src/tools/miri/tests/fail/shims/munmap.stderr deleted file mode 100644 index cb47769c063..00000000000 --- a/src/tools/miri/tests/fail/shims/munmap.stderr +++ /dev/null @@ -1,39 +0,0 @@ -warning: integer-to-pointer cast - --> $DIR/munmap.rs:LL:CC - | -LL | / libc::munmap( -LL | | -LL | | // Some high address we surely have not allocated anything at -LL | | ptr::invalid_mut(1 << 30), -LL | | 4096, -LL | | ) - | |_________^ integer-to-pointer cast - | - = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, - = help: which means that Miri might miss pointer bugs in this program. - = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. - = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. - = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. - = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. - = note: BACKTRACE: - = note: inside `main` at $DIR/munmap.rs:LL:CC - -error: unsupported operation: Miri only supports munmap on memory allocated directly by mmap - --> $DIR/munmap.rs:LL:CC - | -LL | / libc::munmap( -LL | | -LL | | // Some high address we surely have not allocated anything at -LL | | ptr::invalid_mut(1 << 30), -LL | | 4096, -LL | | ) - | |_________^ Miri only supports munmap on memory allocated directly by mmap - | - = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support - = note: BACKTRACE: - = note: inside `main` at $DIR/munmap.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error; 1 warning emitted - diff --git a/src/tools/miri/tests/fail/shims/munmap_partial.rs b/src/tools/miri/tests/fail/shims/munmap_partial.rs deleted file mode 100644 index 938850ee286..00000000000 --- a/src/tools/miri/tests/fail/shims/munmap_partial.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! Our mmap/munmap support is a thin wrapper over Interpcx::allocate_ptr. Since the underlying -//! layer has much more UB than munmap does, we need to be sure we throw an unsupported error here. -//@ignore-target-windows: No libc on Windows - -fn main() { - unsafe { - let ptr = libc::mmap( - std::ptr::null_mut(), - page_size::get() * 2, - libc::PROT_READ | libc::PROT_WRITE, - libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, - -1, - 0, - ); - libc::munmap(ptr, 1); - //~^ ERROR: unsupported operation - } -} diff --git a/src/tools/miri/tests/fail/shims/munmap_partial.stderr b/src/tools/miri/tests/fail/shims/munmap_partial.stderr deleted file mode 100644 index 9a084c50437..00000000000 --- a/src/tools/miri/tests/fail/shims/munmap_partial.stderr +++ /dev/null @@ -1,29 +0,0 @@ -warning: integer-to-pointer cast - --> $DIR/munmap_partial.rs:LL:CC - | -LL | libc::munmap(ptr, 1); - | ^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast - | - = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, - = help: which means that Miri might miss pointer bugs in this program. - = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. - = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. - = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. - = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. - = note: BACKTRACE: - = note: inside `main` at $DIR/munmap_partial.rs:LL:CC - -error: unsupported operation: Miri only supports munmap calls that exactly unmap a region previously returned by mmap - --> $DIR/munmap_partial.rs:LL:CC - | -LL | libc::munmap(ptr, 1); - | ^^^^^^^^^^^^^^^^^^^^ Miri only supports munmap calls that exactly unmap a region previously returned by mmap - | - = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support - = note: BACKTRACE: - = note: inside `main` at $DIR/munmap_partial.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error; 1 warning emitted - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.rs deleted file mode 100644 index 94ca3496ed9..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -/// Test that destroying a pthread_cond twice fails, even without a check for number validity - -fn main() { - unsafe { - use core::mem::MaybeUninit; - let mut attr = MaybeUninit::::uninit(); - libc::pthread_condattr_init(attr.as_mut_ptr()); - - let mut cond = MaybeUninit::::uninit(); - - libc::pthread_cond_init(cond.as_mut_ptr(), attr.as_ptr()); - - libc::pthread_cond_destroy(cond.as_mut_ptr()); - - libc::pthread_cond_destroy(cond.as_mut_ptr()); - //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.stderr deleted file mode 100644 index ecfedf75370..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - --> $DIR/libc_pthread_cond_double_destroy.rs:LL:CC - | -LL | libc::pthread_cond_destroy(cond.as_mut_ptr()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_cond_double_destroy.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.rs deleted file mode 100644 index 13e639a867d..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -/// Test that destroying a pthread_condattr twice fails, even without a check for number validity - -fn main() { - unsafe { - use core::mem::MaybeUninit; - let mut attr = MaybeUninit::::uninit(); - - libc::pthread_condattr_init(attr.as_mut_ptr()); - - libc::pthread_condattr_destroy(attr.as_mut_ptr()); - - libc::pthread_condattr_destroy(attr.as_mut_ptr()); - //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.stderr deleted file mode 100644 index f39d909adbd..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - --> $DIR/libc_pthread_condattr_double_destroy.rs:LL:CC - | -LL | libc::pthread_condattr_destroy(attr.as_mut_ptr()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_condattr_double_destroy.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.rs deleted file mode 100644 index 8b251073383..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ignore-target-windows: No libc on Windows -// -// Check that if we pass NULL attribute, then we get the default mutex type. - -fn main() { - unsafe { - let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); - assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, std::ptr::null() as *const _), 0); - assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); - libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: Undefined Behavior: trying to acquire already locked default mutex - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr deleted file mode 100644 index 4a138e6f8a2..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: trying to acquire already locked default mutex - --> $DIR/libc_pthread_mutex_NULL_deadlock.rs:LL:CC - | -LL | libc::pthread_mutex_lock(&mut mutex as *mut _); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to acquire already locked default mutex - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_mutex_NULL_deadlock.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.rs deleted file mode 100644 index 6c3cb738e29..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct Mutex(UnsafeCell); - -unsafe impl Send for Mutex {} -unsafe impl Sync for Mutex {} - -fn new_lock() -> Arc { - Arc::new(Mutex(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_mutex_lock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_mutex_lock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.stderr deleted file mode 100644 index 599655a8692..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: deadlock: the evaluated program deadlocked - --> $DIR/libc_pthread_mutex_deadlock.rs:LL:CC - | -LL | assert_eq!(libc::pthread_mutex_lock(lock_copy.0.get() as *mut _), 0); - | ^ the evaluated program deadlocked - | - = note: inside closure at $DIR/libc_pthread_mutex_deadlock.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.rs deleted file mode 100644 index f443768819f..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ignore-target-windows: No libc on Windows -// -// Check that if we do not set the mutex type, it is the default. - -fn main() { - unsafe { - let mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); - let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); - assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); - assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); - libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: Undefined Behavior: trying to acquire already locked default mutex - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.stderr deleted file mode 100644 index 8aea3f5c693..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: trying to acquire already locked default mutex - --> $DIR/libc_pthread_mutex_default_deadlock.rs:LL:CC - | -LL | libc::pthread_mutex_lock(&mut mutex as *mut _); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to acquire already locked default mutex - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_mutex_default_deadlock.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.rs deleted file mode 100644 index ec3965c7574..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - unsafe { - let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); - assert_eq!( - libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), - 0, - ); - let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); - assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); - assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); - libc::pthread_mutex_destroy(&mut mutex as *mut _); //~ ERROR: destroyed a locked mutex - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.stderr deleted file mode 100644 index a8ab948116e..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: destroyed a locked mutex - --> $DIR/libc_pthread_mutex_destroy_locked.rs:LL:CC - | -LL | libc::pthread_mutex_destroy(&mut mutex as *mut _); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ destroyed a locked mutex - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_mutex_destroy_locked.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.rs deleted file mode 100644 index 622c3eaeae3..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -/// Test that destroying a pthread_mutex twice fails, even without a check for number validity - -fn main() { - unsafe { - use core::mem::MaybeUninit; - - let mut attr = MaybeUninit::::uninit(); - libc::pthread_mutexattr_init(attr.as_mut_ptr()); - - let mut mutex = MaybeUninit::::uninit(); - - libc::pthread_mutex_init(mutex.as_mut_ptr(), attr.as_ptr()); - - libc::pthread_mutex_destroy(mutex.as_mut_ptr()); - - libc::pthread_mutex_destroy(mutex.as_mut_ptr()); - //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.stderr deleted file mode 100644 index 9620fdbd18b..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - --> $DIR/libc_pthread_mutex_double_destroy.rs:LL:CC - | -LL | libc::pthread_mutex_destroy(mutex.as_mut_ptr()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_mutex_double_destroy.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.rs deleted file mode 100644 index 5ea09fa5aac..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - unsafe { - let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); - assert_eq!( - libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), - 0, - ); - let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); - assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); - assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); - libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: deadlock: the evaluated program deadlocked - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.stderr deleted file mode 100644 index b7877d3aa39..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: deadlock: the evaluated program deadlocked - --> $DIR/libc_pthread_mutex_normal_deadlock.rs:LL:CC - | -LL | libc::pthread_mutex_lock(&mut mutex as *mut _); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program deadlocked - | - = note: inside `main` at $DIR/libc_pthread_mutex_normal_deadlock.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs deleted file mode 100644 index 8ce7542edb8..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - unsafe { - let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); - assert_eq!( - libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), - 0, - ); - let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); - assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); - assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); - assert_eq!(libc::pthread_mutex_unlock(&mut mutex as *mut _), 0); - libc::pthread_mutex_unlock(&mut mutex as *mut _); //~ ERROR: was not locked - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr deleted file mode 100644 index 754137b85b9..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: unlocked a PTHREAD_MUTEX_NORMAL mutex that was not locked by the current thread - --> $DIR/libc_pthread_mutex_normal_unlock_unlocked.rs:LL:CC - | -LL | libc::pthread_mutex_unlock(&mut mutex as *mut _); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked a PTHREAD_MUTEX_NORMAL mutex that was not locked by the current thread - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_mutex_normal_unlock_unlocked.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.rs deleted file mode 100644 index b56775252e4..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct Mutex(UnsafeCell); - -unsafe impl Send for Mutex {} -unsafe impl Sync for Mutex {} - -fn new_lock() -> Arc { - Arc::new(Mutex(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_mutex_lock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_mutex_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked a default mutex that was not locked by the current thread - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.stderr deleted file mode 100644 index aa81b06fc80..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: unlocked a default mutex that was not locked by the current thread - --> $DIR/libc_pthread_mutex_wrong_owner.rs:LL:CC - | -LL | ...t_eq!(libc::pthread_mutex_unlock(lock_copy.0.get() as *mut _), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked a default mutex that was not locked by the current thread - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside closure at $DIR/libc_pthread_mutex_wrong_owner.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.rs deleted file mode 100644 index 474a277516d..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -/// Test that destroying a pthread_mutexattr twice fails, even without a check for number validity - -fn main() { - unsafe { - use core::mem::MaybeUninit; - let mut attr = MaybeUninit::::uninit(); - - libc::pthread_mutexattr_init(attr.as_mut_ptr()); - - libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); - - libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); - //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.stderr deleted file mode 100644 index 82949047d2a..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - --> $DIR/libc_pthread_mutexattr_double_destroy.rs:LL:CC - | -LL | libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_mutexattr_double_destroy.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs deleted file mode 100644 index 603580ff58a..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0); - libc::pthread_rwlock_destroy(rw.get()); //~ ERROR: destroyed a locked rwlock - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr deleted file mode 100644 index be73e7f1e2a..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: destroyed a locked rwlock - --> $DIR/libc_pthread_rwlock_destroy_read_locked.rs:LL:CC - | -LL | libc::pthread_rwlock_destroy(rw.get()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ destroyed a locked rwlock - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_rwlock_destroy_read_locked.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs deleted file mode 100644 index ae44f22d146..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); - libc::pthread_rwlock_destroy(rw.get()); //~ ERROR: destroyed a locked rwlock - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr deleted file mode 100644 index bc2713a5ffb..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: destroyed a locked rwlock - --> $DIR/libc_pthread_rwlock_destroy_write_locked.rs:LL:CC - | -LL | libc::pthread_rwlock_destroy(rw.get()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ destroyed a locked rwlock - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_rwlock_destroy_write_locked.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.rs deleted file mode 100644 index 800986f7506..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -/// Test that destroying a pthread_rwlock twice fails, even without a check for number validity - -fn main() { - unsafe { - let mut lock = libc::PTHREAD_RWLOCK_INITIALIZER; - - libc::pthread_rwlock_destroy(&mut lock); - - libc::pthread_rwlock_destroy(&mut lock); - //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.stderr deleted file mode 100644 index 5004f84358d..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - --> $DIR/libc_pthread_rwlock_double_destroy.rs:LL:CC - | -LL | libc::pthread_rwlock_destroy(&mut lock); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_rwlock_double_destroy.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs deleted file mode 100644 index 782c95b6d2e..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0); - libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr deleted file mode 100644 index 075c8f0ef52..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: deadlock: the evaluated program deadlocked - --> $DIR/libc_pthread_rwlock_read_write_deadlock_single_thread.rs:LL:CC - | -LL | libc::pthread_rwlock_wrlock(rw.get()); - | ^ the evaluated program deadlocked - | - = note: inside `main` at $DIR/libc_pthread_rwlock_read_write_deadlock_single_thread.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs deleted file mode 100644 index 1b498ad8fcd..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct RwLock(UnsafeCell); - -unsafe impl Send for RwLock {} -unsafe impl Sync for RwLock {} - -fn new_lock() -> Arc { - Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_rwlock_rdlock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked an rwlock that was not locked by the active thread - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr deleted file mode 100644 index 7dfa27b43d0..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: unlocked an rwlock that was not locked by the active thread - --> $DIR/libc_pthread_rwlock_read_wrong_owner.rs:LL:CC - | -LL | ... assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked an rwlock that was not locked by the active thread - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside closure at $DIR/libc_pthread_rwlock_read_wrong_owner.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs deleted file mode 100644 index 05f7e7a06c5..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - libc::pthread_rwlock_unlock(rw.get()); //~ ERROR: was not locked - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr deleted file mode 100644 index 1c25ac2c048..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: unlocked an rwlock that was not locked by the active thread - --> $DIR/libc_pthread_rwlock_unlock_unlocked.rs:LL:CC - | -LL | libc::pthread_rwlock_unlock(rw.get()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked an rwlock that was not locked by the active thread - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside `main` at $DIR/libc_pthread_rwlock_unlock_unlocked.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs deleted file mode 100644 index 201844615e1..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct RwLock(UnsafeCell); - -unsafe impl Send for RwLock {} -unsafe impl Sync for RwLock {} - -fn new_lock() -> Arc { - Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_rwlock_rdlock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr deleted file mode 100644 index 333fb1afb91..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: deadlock: the evaluated program deadlocked - --> $DIR/libc_pthread_rwlock_write_read_deadlock.rs:LL:CC - | -LL | assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); - | ^ the evaluated program deadlocked - | - = note: inside closure at $DIR/libc_pthread_rwlock_write_read_deadlock.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs deleted file mode 100644 index 538f14ef89f..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); - libc::pthread_rwlock_rdlock(rw.get()); //~ ERROR: deadlock - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr deleted file mode 100644 index caab19a782f..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: deadlock: the evaluated program deadlocked - --> $DIR/libc_pthread_rwlock_write_read_deadlock_single_thread.rs:LL:CC - | -LL | libc::pthread_rwlock_rdlock(rw.get()); - | ^ the evaluated program deadlocked - | - = note: inside `main` at $DIR/libc_pthread_rwlock_write_read_deadlock_single_thread.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs deleted file mode 100644 index b1d7e0492e5..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct RwLock(UnsafeCell); - -unsafe impl Send for RwLock {} -unsafe impl Sync for RwLock {} - -fn new_lock() -> Arc { - Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_rwlock_wrlock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr deleted file mode 100644 index 93bede54fcf..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: deadlock: the evaluated program deadlocked - --> $DIR/libc_pthread_rwlock_write_write_deadlock.rs:LL:CC - | -LL | assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); - | ^ the evaluated program deadlocked - | - = note: inside closure at $DIR/libc_pthread_rwlock_write_write_deadlock.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs deleted file mode 100644 index 2c963d36510..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); - libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr deleted file mode 100644 index 30f5f447c71..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: deadlock: the evaluated program deadlocked - --> $DIR/libc_pthread_rwlock_write_write_deadlock_single_thread.rs:LL:CC - | -LL | libc::pthread_rwlock_wrlock(rw.get()); - | ^ the evaluated program deadlocked - | - = note: inside `main` at $DIR/libc_pthread_rwlock_write_write_deadlock_single_thread.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs deleted file mode 100644 index dd099474d8f..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct RwLock(UnsafeCell); - -unsafe impl Send for RwLock {} -unsafe impl Sync for RwLock {} - -fn new_lock() -> Arc { - Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_rwlock_wrlock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked an rwlock that was not locked by the active thread - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr deleted file mode 100644 index 5bf402c775a..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: unlocked an rwlock that was not locked by the active thread - --> $DIR/libc_pthread_rwlock_write_wrong_owner.rs:LL:CC - | -LL | ... assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked an rwlock that was not locked by the active thread - | - = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior - = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information - = note: BACKTRACE: - = note: inside closure at $DIR/libc_pthread_rwlock_write_wrong_owner.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/tokio/sleep.rs b/src/tools/miri/tests/fail/tokio/sleep.rs deleted file mode 100644 index d96d778e6ca..00000000000 --- a/src/tools/miri/tests/fail/tokio/sleep.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@compile-flags: -Zmiri-permissive-provenance -Zmiri-backtrace=full -//@only-target-x86_64-unknown-linux: support for tokio only on linux and x86 -//@error-in-other-file: returning ready events from epoll_wait is not yet implemented -//@normalize-stderr-test: " += note:.*\n" -> "" - -use tokio::time::{sleep, Duration, Instant}; - -#[tokio::main] -async fn main() { - let start = Instant::now(); - sleep(Duration::from_secs(1)).await; - let time_elapsed = &start.elapsed().as_millis(); - assert!((1000..1100).contains(time_elapsed), "{}", time_elapsed); -} diff --git a/src/tools/miri/tests/fail/tokio/sleep.stderr b/src/tools/miri/tests/fail/tokio/sleep.stderr deleted file mode 100644 index ac2a984ed51..00000000000 --- a/src/tools/miri/tests/fail/tokio/sleep.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: unsupported operation: returning ready events from epoll_wait is not yet implemented - --> CARGO_REGISTRY/.../epoll.rs:LL:CC - | -LL | / syscall!(epoll_wait( -LL | | self.ep, -LL | | events.as_mut_ptr(), -LL | | events.capacity() as i32, -LL | | timeout, -LL | | )) - | |__________^ returning ready events from epoll_wait is not yet implemented - | - = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/unsupported_incomplete_function.rs b/src/tools/miri/tests/fail/unsupported_incomplete_function.rs deleted file mode 100644 index 6ef842c9ccb..00000000000 --- a/src/tools/miri/tests/fail/unsupported_incomplete_function.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! `signal()` is special on Linux and macOS that it's only supported within libstd. -//! The implementation is not complete enough to permit user code to call it. -//@ignore-target-windows: No libc on Windows -//@normalize-stderr-test: "OS `.*`" -> "$$OS" - -fn main() { - unsafe { - libc::signal(libc::SIGPIPE, libc::SIG_IGN); - //~^ ERROR: unsupported operation: can't call foreign function `signal` - } -} diff --git a/src/tools/miri/tests/fail/unsupported_incomplete_function.stderr b/src/tools/miri/tests/fail/unsupported_incomplete_function.stderr deleted file mode 100644 index ec2bba61172..00000000000 --- a/src/tools/miri/tests/fail/unsupported_incomplete_function.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unsupported operation: can't call foreign function `signal` on $OS - --> $DIR/unsupported_incomplete_function.rs:LL:CC - | -LL | libc::signal(libc::SIGPIPE, libc::SIG_IGN); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `signal` on $OS - | - = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support - = note: BACKTRACE: - = note: inside `main` at $DIR/unsupported_incomplete_function.rs:LL:CC - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - -- cgit 1.4.1-3-g733a5