Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libc/src/__support/OSUtil/linux/auxv.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <linux/auxvec.h> // For AT_ macros
#include <linux/mman.h> // For mmap flags
#include <linux/param.h> // For EXEC_PAGESIZE
#include <linux/prctl.h> // For prctl
#include <sys/syscall.h> // For syscall numbers

Expand Down Expand Up @@ -90,7 +91,7 @@ LIBC_INLINE void Vector::fallback_initialize_unsync() {
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
// We do not proceed if mmap fails.
if (mmap_ret <= 0)
if (mmap_ret <= 0 && mmap_ret > -EXEC_PAGESIZE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should restrict this extra condition to RV32 only, and add comments to explain the reason.

Copy link
Contributor Author

@SchrodingerZhu SchrodingerZhu Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (ret < 0 && ret > -EXEC_PAGESIZE) {

So the original mmap.cpp always have this check logic.

However, I read the comment again and the argument looks suspicious. EXEC_PAGESIZE is not always the page size in general.

Inside linux kernel, the logic is defined in https://elixir.bootlin.com/linux/v6.17.1/source/tools/include/linux/err.h#L33.

I think the checking logic should be provided as a common function and used in both cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a common check function and link to the linux kernel would be great.

return;

// Initialize the auxv array with AT_NULL entries.
Expand Down
Loading