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 18, 2024
1 parent 9e20f93 commit eff82df
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 21 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: 10 additions & 9 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,35 @@ 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::<()>();
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();
GLOBAL_ALLOCATOR.0.as_ref().unwrap().pool.execute(move || {
log::info!("gc {}: stucked, waiting for unstuck...", c.id);
let mut first = true;
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);
drop(mutex);
sender.send(()).unwrap();
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));
drop(mutex);
c.safepoint();
}
}
});
}
startrecv.recv().unwrap();
STUCK_COND.notify_all();
// FRAMES_LIST.0.lock().borrow_mut().insert( self as _,frames);
}
Expand All @@ -1063,11 +1067,8 @@ impl Collector {
}

pub fn unstuck(&mut self) {
log::trace!("gc {}: unstucking...", self.id);
self.stuck_stop_notify_chan.0.send(()).unwrap();
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();

Expand Down
1 change: 0 additions & 1 deletion immix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ 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!("start add_root");
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");
}
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 {:?}",
o,
);
drop(l);
}
Expand Down
2 changes: 0 additions & 2 deletions vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@ fn new_thread(f: *mut i128) {
#[is_runtime]
fn sleep(secs: u64) {
// gc::DioGC__stuck_begin(sp);
println!("sleeping for {} secs", secs);
thread::sleep(std::time::Duration::from_secs(secs));
// gc::DioGC__stuck_end();
println!("sleeping done");
}

#[is_runtime]
Expand Down
1 change: 0 additions & 1 deletion vm/src/mutex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ fn condvar_wait(cond: *mut Condvar, mutex: *mut OpaqueMutex) -> u64 {
let cond = unsafe { &*cond };
let lock = cond.wait::<()>(lock).unwrap();
container.guard.set(Some(lock));

0
}

Expand Down

0 comments on commit eff82df

Please sign in to comment.