-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dump process map on mmap
failure and fix typos
#1127
Merged
k-sareen
merged 4 commits into
mmtk:master
from
k-sareen:fix/misc-typos-and-comment-formatting
Apr 24, 2024
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,6 +147,7 @@ pub fn handle_mmap_error<VM: VMBinding>(error: Error, tls: VMThread) -> ! { | |
match error.kind() { | ||
// From Rust nightly 2021-05-12, we started to see Rust added this ErrorKind. | ||
ErrorKind::OutOfMemory => { | ||
eprintln!("{}", get_process_memory_maps()); | ||
// Signal `MmapOutOfMemory`. Expect the VM to abort immediately. | ||
trace!("Signal MmapOutOfMemory!"); | ||
VM::VMCollection::out_of_memory(tls, AllocationError::MmapOutOfMemory); | ||
|
@@ -159,14 +160,18 @@ pub fn handle_mmap_error<VM: VMBinding>(error: Error, tls: VMThread) -> ! { | |
if let Some(os_errno) = error.raw_os_error() { | ||
// If it is OOM, we invoke out_of_memory() through the VM interface. | ||
if os_errno == libc::ENOMEM { | ||
eprintln!("{}", get_process_memory_maps()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is OOM, too. We may rely on the default impl of |
||
// Signal `MmapOutOfMemory`. Expect the VM to abort immediately. | ||
trace!("Signal MmapOutOfMemory!"); | ||
VM::VMCollection::out_of_memory(tls, AllocationError::MmapOutOfMemory); | ||
unreachable!() | ||
} | ||
} | ||
} | ||
ErrorKind::AlreadyExists => panic!("Failed to mmap, the address is already mapped. Should MMTk quanrantine the address range first?"), | ||
ErrorKind::AlreadyExists => { | ||
eprintln!("{}", get_process_memory_maps()); | ||
k-sareen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
panic!("Failed to mmap, the address is already mapped. Should MMTk quarantine the address range first?"); | ||
} | ||
_ => {} | ||
} | ||
panic!("Unexpected mmap failure: {:?}", error) | ||
|
@@ -229,8 +234,7 @@ fn wrap_libc_call<T: PartialEq>(f: &dyn Fn() -> T, expect: T) -> Result<()> { | |
/// Get the memory maps for the process. The returned string is a multi-line string. | ||
/// This is only meant to be used for debugging. For example, log process memory maps after detecting a clash. | ||
/// If we would need to parsable memory maps, I would suggest using a library instead which saves us the trouble to deal with portability. | ||
#[cfg(debug_assertions)] | ||
#[cfg(target_os = "linux")] | ||
#[cfg(any(target_os = "linux", target_os = "android"))] | ||
pub fn get_process_memory_maps() -> String { | ||
// print map | ||
use std::fs::File; | ||
|
@@ -241,6 +245,11 @@ pub fn get_process_memory_maps() -> String { | |
data | ||
} | ||
|
||
#[cfg(not(any(target_os = "linux", target_os = "android")))] | ||
pub fn get_process_memory_maps() -> String { | ||
"(process map unavailable)".to_string() | ||
} | ||
|
||
/// Returns the total physical memory for the system in bytes. | ||
pub(crate) fn get_system_total_memory() -> u64 { | ||
// TODO: Note that if we want to get system info somewhere else in the future, we should | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I just realised that the out-of-memory event is not always lethal because the VM binding can implement
VM::VMCollection::out_of_memory
. If the VM can recover from OOM (like OpenJDK), it is probably unnecessary to print the memory maps. But if it crashes (like when OpenJDK generates something likehs_err_pidXXXXX.log
), the ability to print mmap would be helpful. I think if there is a call toVM::VMCollection::out_of_memory
following this, we should move it to the default implementation ofCollection::out_of_memory
(because it panics anyway).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this is different. This is an
mmap
error, not a simple OOM error. The simple OOM error isAllocationError::HeapOutOfMemory
. As it says in the comment below the inserted line: "Expect the VM to abort immediately"