Skip to content

Commit 0883898

Browse files
authored
Update CI macos image (#1216)
macos-12 will no longer be supported: actions/runner-images#10721
1 parent 328deb6 commit 0883898

File tree

6 files changed

+44
-9
lines changed

6 files changed

+44
-9
lines changed

.github/workflows/minimal-tests-core.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
target:
3737
- { os: ubuntu-22.04, triple: x86_64-unknown-linux-gnu }
3838
- { os: ubuntu-22.04, triple: i686-unknown-linux-gnu }
39-
- { os: macos-12, triple: x86_64-apple-darwin }
39+
- { os: macos-15, triple: x86_64-apple-darwin }
4040
rust: ${{ fromJson(needs.setup-test-matrix.outputs.rust )}}
4141

4242
name: minimal-tests-core/${{ matrix.target.triple }}/${{ matrix.rust }}

src/policy/space.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub trait Space<VM: VMBinding>: 'static + SFT + Sync + Downcast {
151151
.try_map_metadata_space(res.start, bytes),
152152
)
153153
{
154-
memory::handle_mmap_error::<VM>(mmap_error, tls);
154+
memory::handle_mmap_error::<VM>(mmap_error, tls, res.start, bytes);
155155
}
156156
};
157157
let grow_space = || {

src/util/memory.rs

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,20 @@ pub fn munmap(start: Address, size: usize) -> Result<()> {
187187

188188
/// Properly handle errors from a mmap Result, including invoking the binding code in the case of
189189
/// an OOM error.
190-
pub fn handle_mmap_error<VM: VMBinding>(error: Error, tls: VMThread) -> ! {
190+
pub fn handle_mmap_error<VM: VMBinding>(
191+
error: Error,
192+
tls: VMThread,
193+
addr: Address,
194+
bytes: usize,
195+
) -> ! {
191196
use std::io::ErrorKind;
192197

198+
eprintln!("Failed to mmap {}, size {}", addr, bytes);
199+
eprintln!("{}", get_process_memory_maps());
200+
193201
match error.kind() {
194202
// From Rust nightly 2021-05-12, we started to see Rust added this ErrorKind.
195203
ErrorKind::OutOfMemory => {
196-
eprintln!("{}", get_process_memory_maps());
197204
// Signal `MmapOutOfMemory`. Expect the VM to abort immediately.
198205
trace!("Signal MmapOutOfMemory!");
199206
VM::VMCollection::out_of_memory(tls, AllocationError::MmapOutOfMemory);
@@ -206,7 +213,6 @@ pub fn handle_mmap_error<VM: VMBinding>(error: Error, tls: VMThread) -> ! {
206213
if let Some(os_errno) = error.raw_os_error() {
207214
// If it is OOM, we invoke out_of_memory() through the VM interface.
208215
if os_errno == libc::ENOMEM {
209-
eprintln!("{}", get_process_memory_maps());
210216
// Signal `MmapOutOfMemory`. Expect the VM to abort immediately.
211217
trace!("Signal MmapOutOfMemory!");
212218
VM::VMCollection::out_of_memory(tls, AllocationError::MmapOutOfMemory);
@@ -215,12 +221,10 @@ pub fn handle_mmap_error<VM: VMBinding>(error: Error, tls: VMThread) -> ! {
215221
}
216222
}
217223
ErrorKind::AlreadyExists => {
218-
eprintln!("{}", get_process_memory_maps());
219224
panic!("Failed to mmap, the address is already mapped. Should MMTk quarantine the address range first?");
220225
}
221226
_ => {}
222227
}
223-
eprintln!("{}", get_process_memory_maps());
224228
panic!("Unexpected mmap failure: {:?}", error)
225229
}
226230

@@ -301,7 +305,34 @@ pub fn get_process_memory_maps() -> String {
301305

302306
/// Get the memory maps for the process. The returned string is a multi-line string.
303307
/// This is only meant to be used for debugging. For example, log process memory maps after detecting a clash.
304-
#[cfg(not(any(target_os = "linux", target_os = "android")))]
308+
#[cfg(target_os = "macos")]
309+
pub fn get_process_memory_maps() -> String {
310+
// Get the current process ID (replace this with a specific PID if needed)
311+
let pid = std::process::id();
312+
313+
// Execute the vmmap command
314+
let output = std::process::Command::new("vmmap")
315+
.arg(pid.to_string()) // Pass the PID as an argument
316+
.output() // Capture the output
317+
.expect("Failed to execute vmmap command");
318+
319+
// Check if the command was successful
320+
if output.status.success() {
321+
// Convert the command output to a string
322+
let output_str =
323+
std::str::from_utf8(&output.stdout).expect("Failed to convert output to string");
324+
output_str.to_string()
325+
} else {
326+
// Handle the error case
327+
let error_message =
328+
std::str::from_utf8(&output.stderr).expect("Failed to convert error message to string");
329+
panic!("Failed to get process memory map: {}", error_message)
330+
}
331+
}
332+
333+
/// Get the memory maps for the process. The returned string is a multi-line string.
334+
/// This is only meant to be used for debugging. For example, log process memory maps after detecting a clash.
335+
#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "macos")))]
305336
pub fn get_process_memory_maps() -> String {
306337
"(process map unavailable)".to_string()
307338
}

src/vm/tests/mock_tests/mock_test_handle_mmap_conflict.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub fn test_handle_mmap_conflict() {
2222
memory::handle_mmap_error::<MockVM>(
2323
mmap2_res.err().unwrap(),
2424
VMThread::UNINITIALIZED,
25+
start,
26+
one_megabyte,
2527
);
2628
});
2729

src/vm/tests/mock_tests/mock_test_handle_mmap_oom.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub fn test_handle_mmap_oom() {
2424
memory::handle_mmap_error::<MockVM>(
2525
mmap_res.err().unwrap(),
2626
VMThread::UNINITIALIZED,
27+
start,
28+
LARGE_SIZE,
2729
);
2830
});
2931
assert!(panic_res.is_err());

src/vm/tests/mock_tests/mock_test_vm_layout_compressed_pointer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn test_vm_layout_compressed_pointer() {
1515
|| {
1616
let start = if cfg!(target_os = "macos") {
1717
// Impossible to map 0x4000_0000 on maocOS. SO choose a different address.
18-
0x40_0000_0000
18+
0x2_0000_0000
1919
} else {
2020
0x4000_0000
2121
};

0 commit comments

Comments
 (0)