CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
105 lines
2.6 KiB
C
105 lines
2.6 KiB
C
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.fuchsia.Lock -verify %s
|
|
|
|
typedef int spin_lock_t;
|
|
typedef int zx_status_t;
|
|
typedef int zx_time_t;
|
|
|
|
void spin_lock(spin_lock_t *lock);
|
|
int spin_trylock(spin_lock_t *lock);
|
|
void spin_unlock(spin_lock_t *lock);
|
|
void spin_lock_init(spin_lock_t *lock);
|
|
|
|
void spin_lock_save(spin_lock_t *lock, void *statep,
|
|
int flags);
|
|
void spin_unlock_restore(spin_lock_t *lock, void *old_state,
|
|
int flags);
|
|
|
|
spin_lock_t mtx1;
|
|
spin_lock_t mtx2;
|
|
|
|
void bad1(void)
|
|
{
|
|
spin_lock(&mtx1); // no-warning
|
|
spin_lock(&mtx1); // expected-warning{{This lock has already been acquired}}
|
|
}
|
|
|
|
void bad2(void) {
|
|
spin_lock(&mtx1);
|
|
spin_unlock(&mtx1);
|
|
spin_unlock(&mtx1); // expected-warning {{This lock has already been unlocked}}
|
|
}
|
|
|
|
void bad3(void) {
|
|
spin_lock_init(&mtx1);
|
|
if (spin_trylock(&mtx1) != 0)
|
|
spin_unlock(&mtx1); // expected-warning {{This lock has already been unlocked}}
|
|
}
|
|
|
|
void bad4(void) {
|
|
spin_lock(&mtx1);
|
|
spin_lock(&mtx2);
|
|
spin_unlock(&mtx1); // expected-warning {{This was not the most recently acquired lock. Possible lock order reversal}}
|
|
spin_unlock(&mtx2);
|
|
}
|
|
|
|
void good(void) {
|
|
spin_lock_t mtx;
|
|
spin_lock_init(&mtx);
|
|
spin_lock_save(&mtx, 0, 0);
|
|
spin_unlock_restore(&mtx, 0, 0);
|
|
}
|
|
|
|
void good2(void) {
|
|
spin_lock_t mtx;
|
|
spin_lock_init(&mtx);
|
|
if (spin_trylock(&mtx) == 0)
|
|
spin_unlock(&mtx);
|
|
}
|
|
|
|
typedef int sync_mutex_t;
|
|
void sync_mutex_lock(sync_mutex_t* mutex);
|
|
void sync_mutex_lock_with_waiter(sync_mutex_t* mutex);
|
|
zx_status_t sync_mutex_timedlock(sync_mutex_t* mutex, zx_time_t deadline);
|
|
zx_status_t sync_mutex_trylock(sync_mutex_t* mutex);
|
|
void sync_mutex_unlock(sync_mutex_t* mutex);
|
|
|
|
sync_mutex_t smtx1;
|
|
sync_mutex_t smtx2;
|
|
|
|
void bad11(void)
|
|
{
|
|
sync_mutex_lock(&smtx1); // no-warning
|
|
sync_mutex_lock(&smtx1); // expected-warning{{This lock has already been acquired}}
|
|
}
|
|
|
|
void bad12(void) {
|
|
sync_mutex_lock_with_waiter(&smtx1);
|
|
sync_mutex_unlock(&smtx1);
|
|
sync_mutex_unlock(&smtx1); // expected-warning {{This lock has already been unlocked}}
|
|
}
|
|
|
|
void bad13(void) {
|
|
sync_mutex_unlock(&smtx1);
|
|
if (sync_mutex_trylock(&smtx1) != 0)
|
|
sync_mutex_unlock(&smtx1); // expected-warning {{This lock has already been unlocked}}
|
|
}
|
|
|
|
void bad14(void) {
|
|
sync_mutex_lock(&smtx1);
|
|
sync_mutex_lock(&smtx2);
|
|
sync_mutex_unlock(&smtx1); // expected-warning {{This was not the most recently acquired lock. Possible lock order reversal}}
|
|
sync_mutex_unlock(&smtx2);
|
|
}
|
|
|
|
void good11(void) {
|
|
sync_mutex_t mtx;
|
|
if (sync_mutex_trylock(&mtx) == 0)
|
|
sync_mutex_unlock(&mtx);
|
|
}
|
|
|
|
void good12(void) {
|
|
sync_mutex_t mtx;
|
|
if (sync_mutex_timedlock(&mtx, 0) == 0)
|
|
sync_mutex_unlock(&mtx);
|
|
}
|