Skip to content

Commit

Permalink
ci: try fix ci hang
Browse files Browse the repository at this point in the history
  • Loading branch information
Chronostasys committed May 17, 2024
1 parent feb2806 commit c7452d7
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: llvm-cov
args: nextest --workspace --all-features --lcov --output-path lcov.info --profile ci -vv --no-capture
args: nextest --workspace --all-features --lcov --output-path lcov.info --profile ci -vv

- name: Upload coverage to Codecov
uses: codecov/[email protected]
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ codegen-units = 1

[dev-dependencies]
expect-test = "1.4.1"
wait-timeout = "0.2.0"

[build-dependencies]
vergen = { version = "8.3.1", features = [
Expand Down
19 changes: 13 additions & 6 deletions immix/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{
mpsc::{channel, Receiver, Sender},
Arc,
},
time::{Duration, Instant},
};

use libc::malloc;
Expand Down Expand Up @@ -1013,32 +1014,40 @@ impl Collector {
pub fn stuck_fast_unwind(&mut self, sp: *mut u8) {
log::trace!("gc {}: stucking...", self.id);
let frames = self.get_frames(sp);
let (startsender, startrecv) = channel::<()>();

Check warning on line 1017 in immix/src/collector.rs

View check run for this annotation

Codecov / codecov/patch

immix/src/collector.rs#L1017

Added line #L1017 was not covered by tests
unsafe {
let ptr = Box::leak(frames) as *mut _;
self.frames_list.store(ptr, Ordering::SeqCst);
let c: *mut Collector = self as *mut _;
let c = c.as_mut().unwrap();
let sender = c.stuck_stopped_notify_chan.0.clone();

Check warning on line 1023 in immix/src/collector.rs

View check run for this annotation

Codecov / codecov/patch

immix/src/collector.rs#L1023

Added line #L1023 was not covered by tests
GLOBAL_ALLOCATOR.0.as_ref().unwrap().pool.execute(move || {
log::info!("gc {}: stucked, waiting for unstuck...", c.id);
println!("gc {}: stucked, waiting for unstuck...", c.id);
let mut first = true;

Check warning on line 1026 in immix/src/collector.rs

View check run for this annotation

Codecov / codecov/patch

immix/src/collector.rs#L1025-L1026

Added lines #L1025 - L1026 were not covered by tests
loop {
let mut mutex = STUCK_MUTEX.lock();
if first {
first = false;
startsender.send(()).unwrap();
}
if c.stuck_stop_notify_chan.1.try_recv().is_ok() {
log::trace!("gc {}: unstucking break...", c.id);
println!("gc {}: unstucking break...", c.id);

Check warning on line 1034 in immix/src/collector.rs

View check run for this annotation

Codecov / codecov/patch

immix/src/collector.rs#L1029-L1034

Added lines #L1029 - L1034 were not covered by tests
drop(mutex);
sender.send(()).unwrap();

Check warning on line 1036 in immix/src/collector.rs

View check run for this annotation

Codecov / codecov/patch

immix/src/collector.rs#L1036

Added line #L1036 was not covered by tests
break;
} else if GC_RUNNING.load(Ordering::Acquire) {
drop(mutex);
c.collect();
} else {
STUCK_COND.wait(&mut mutex);
STUCK_COND
.wait_until(&mut mutex, Instant::now() + Duration::from_millis(100));

Check warning on line 1043 in immix/src/collector.rs

View check run for this annotation

Codecov / codecov/patch

immix/src/collector.rs#L1042-L1043

Added lines #L1042 - L1043 were not covered by tests
drop(mutex);
c.safepoint();
}
}
});
}
startrecv.recv().unwrap();

Check warning on line 1050 in immix/src/collector.rs

View check run for this annotation

Codecov / codecov/patch

immix/src/collector.rs#L1050

Added line #L1050 was not covered by tests
STUCK_COND.notify_all();
// FRAMES_LIST.0.lock().borrow_mut().insert( self as _,frames);
}
Expand All @@ -1063,11 +1072,9 @@ impl Collector {
}

pub fn unstuck(&mut self) {
log::trace!("gc {}: unstucking...", self.id);
println!("gc {}: unstucking...", self.id);
self.stuck_stop_notify_chan.0.send(()).unwrap();

Check warning on line 1076 in immix/src/collector.rs

View check run for this annotation

Codecov / codecov/patch

immix/src/collector.rs#L1075-L1076

Added lines #L1075 - L1076 were not covered by tests
let mutex = STUCK_MUTEX.lock();
STUCK_COND.notify_all();
drop(mutex);
// wait until the shadow thread exit
self.stuck_stopped_notify_chan.1.recv().unwrap();

Check warning on line 1080 in immix/src/collector.rs

View check run for this annotation

Codecov / codecov/patch

immix/src/collector.rs#L1079-L1080

Added lines #L1079 - L1080 were not covered by tests
Expand Down
2 changes: 1 addition & 1 deletion immix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ pub fn thread_stuck_start_fast(sp: *mut u8) {
/// will block until the gc is finished
pub fn thread_stuck_end() {
log::trace!("unstucking...");
spin_until!(!GC_RUNNING.load(Ordering::SeqCst));
// v.0 += 1;
SPACE.with(|gc| {
println!("{} enter unstuck", gc.borrow().get_id());

Check warning on line 298 in immix/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

immix/src/lib.rs#L298

Added line #L298 was not covered by tests
// println!("start add_root");
let mut gc = gc.borrow_mut();
gc.unstuck()
Expand Down
22 changes: 15 additions & 7 deletions src/ast/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use lsp_types::{
};
use rustc_hash::FxHashMap;
use salsa::{accumulator::Accumulator, storage::HasJar};
use wait_timeout::ChildExt;

use crate::{
ast::{
Expand Down Expand Up @@ -505,15 +506,22 @@ fn test_compile() {
let exe = crate::utils::canonicalize(&exe)
.unwrap_or_else(|_| panic!("static compiled file not found {:?}", exe));
eprintln!("exec: {:?}", exe);
let o = Command::new(exe.to_str().unwrap())
.output()
let mut child = Command::new(exe.to_str().unwrap())
.spawn()
.expect("failed to execute compiled program");

let o = child
.wait_timeout(std::time::Duration::from_secs(50))
.expect("failed to wait on child");
if o.is_none() {
child.kill().expect("failed to kill child");
panic!("compiled program timed out");

Check warning on line 518 in src/ast/test.rs

View check run for this annotation

Codecov / codecov/patch

src/ast/test.rs#L517-L518

Added lines #L517 - L518 were not covered by tests
}
let o = o.unwrap();
assert!(
o.status.success(),
"static compiled program failed with status {:?} and output {:?} and error {:?}",
o.status,
String::from_utf8_lossy(&o.stdout),
String::from_utf8_lossy(&o.stderr)
o.success(),
"static compiled program failed with status {:?}",

Check warning on line 523 in src/ast/test.rs

View check run for this annotation

Codecov / codecov/patch

src/ast/test.rs#L523

Added line #L523 was not covered by tests
o,
);
drop(l);
}
Expand Down
4 changes: 3 additions & 1 deletion vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ fn new_thread(f: *mut i128) {
#[is_runtime]
fn sleep(secs: u64) {
// gc::DioGC__stuck_begin(sp);
println!("sleep threadid {:?}", thread::current().id());

Check warning on line 127 in vm/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

vm/src/lib.rs#L127

Added line #L127 was not covered by tests
println!("sleeping for {} secs", secs);
thread::sleep(std::time::Duration::from_secs(secs));
// gc::DioGC__stuck_end();
println!("sleeping done");
println!("sleeping done {} secs", secs);
println!("sleep done threadid {:?}", thread::current().id());

Check warning on line 132 in vm/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

vm/src/lib.rs#L131-L132

Added lines #L131 - L132 were not covered by tests
}

#[is_runtime]
Expand Down
9 changes: 8 additions & 1 deletion vm/src/mutex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ fn create_mutex(mutex: *mut *mut OpaqueMutex) -> u64 {

#[is_runtime]
fn lock_mutex(mutex: *mut OpaqueMutex) -> u64 {
use std::thread;

println!("lock threadid {:?}", thread::current().id());

Check warning on line 40 in vm/src/mutex/mod.rs

View check run for this annotation

Codecov / codecov/patch

vm/src/mutex/mod.rs#L38-L40

Added lines #L38 - L40 were not covered by tests
let container: &MutexContainer = &*mutex.cast();
// immix::thread_stuck_start();
let lock: MutexGuard<'static, _> = mem::transmute(container.mutex.lock().unwrap());
// immix::thread_stuck_end();
container.guard.set(Some(lock));
println!("lock done threadid {:?}", thread::current().id());

Check warning on line 46 in vm/src/mutex/mod.rs

View check run for this annotation

Codecov / codecov/patch

vm/src/mutex/mod.rs#L46

Added line #L46 was not covered by tests
0
}

Expand Down Expand Up @@ -76,12 +80,15 @@ fn drop_condvar(cond: *mut Condvar) -> u64 {

#[is_runtime]
fn condvar_wait(cond: *mut Condvar, mutex: *mut OpaqueMutex) -> u64 {
use std::thread;

println!("condvar threadid {:?}", thread::current().id());

Check warning on line 85 in vm/src/mutex/mod.rs

View check run for this annotation

Codecov / codecov/patch

vm/src/mutex/mod.rs#L83-L85

Added lines #L83 - L85 were not covered by tests
let container: &MutexContainer = &*mutex.cast();
let lock = container.guard.replace(None).unwrap();
let cond = unsafe { &*cond };
let lock = cond.wait::<()>(lock).unwrap();
container.guard.set(Some(lock));

println!("condvar done threadid {:?}", thread::current().id());

Check warning on line 91 in vm/src/mutex/mod.rs

View check run for this annotation

Codecov / codecov/patch

vm/src/mutex/mod.rs#L91

Added line #L91 was not covered by tests
0
}

Expand Down

0 comments on commit c7452d7

Please sign in to comment.