* madvise failed: Invalid argument
@ 2024-08-13 2:01 Felix Lechner via Developers list for Guile, the GNU extensibility library
2024-08-13 3:21 ` Olivier Dion
0 siblings, 1 reply; 2+ messages in thread
From: Felix Lechner via Developers list for Guile, the GNU extensibility library @ 2024-08-13 2:01 UTC (permalink / raw)
To: guile-devel
Hi,
Would someone please help me understand the warning message
madvise failed: Invalid argument
in my code?
In my newest project, I hope to offer users a more convenient way to
configure authentication tasks and partially reimplemented Linux-PAM in
GNU Guile. [1]
The online manual is the most convenient way to read about it. [2]
My code uses an ELF shared object called pam_guile.so to call Guile via
the interface described in the Tortoise tutorial. [3] The warning
probably originates here:
ret = madvise ((void *) lo, hi - lo, MADV_DONTNEED); [4]
From my reading, that call is meant to return stack space back to the
operating system. According to the madvise(2) manual page [5] the
variable 'lo' must be page-aligned, but apparently isn't.
Why would the 'stack_bottom' not be page aligned, please? Could it be
mitigated by alignment instructions in my ELF shared object?
Thank you for looking!
Kind regards
Felix
P.S. Please copy me explicitly. I do not subscribe to your list.
[1] https://codeberg.org/lechner/guile-pam
[2] https://juix.org/guile-pam/
[3] https://www.gnu.org/software/guile/docs/guile-tut/tutorial.html
[4] https://git.savannah.gnu.org/cgit/guile.git/tree/libguile/vm.c#n651
[5] https://www.man7.org/linux/man-pages/man2/madvise.2.html
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: madvise failed: Invalid argument
2024-08-13 2:01 madvise failed: Invalid argument Felix Lechner via Developers list for Guile, the GNU extensibility library
@ 2024-08-13 3:21 ` Olivier Dion
0 siblings, 0 replies; 2+ messages in thread
From: Olivier Dion @ 2024-08-13 3:21 UTC (permalink / raw)
To: Felix Lechner, guile-devel
On Mon, 12 Aug 2024, Felix Lechner via "Developers list for Guile, the GNU extensibility library" <guile-devel@gnu.org> wrote:
> Hi,
[...]
> The warning probably originates here:
>
> ret = madvise ((void *) lo, hi - lo, MADV_DONTNEED); [4]
>
> From my reading, that call is meant to return stack space back to the
> operating system. According to the madvise(2) manual page [5] the
> variable 'lo' must be page-aligned, but apparently isn't.
>
> Why would the 'stack_bottom' not be page aligned, please? Could it be
> mitigated by alignment instructions in my ELF shared object?
The argument passed to `madvise(2)' is page aligned correcly. See the
round down with `lo &= ~(page_size - 1U); /* round down */' just above
the call.
The following is possible for EINVAL to be returned:
1) hi - lo < page_size
2) lenght = hi - lo; lo + lenght < lo => Unsigned integer overflow
3) The memory range is locked. See mlock(2)
4) The variable `page_size' is zero for some reason (highly doubt)
You can check for all of the above with a debugger or `strace(1)'
easily.
Regards,
Olivier
--
Olivier Dion
oldiob.ca
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-13 3:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-13 2:01 madvise failed: Invalid argument Felix Lechner via Developers list for Guile, the GNU extensibility library
2024-08-13 3:21 ` Olivier Dion
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).