[haiku-development] Re: replacing runtime_loader
- From: Tim Kelly <gtkelly@xxxxxxxxxxxxxxxxx>
- To: haiku-development@xxxxxxxxxxxxx
- Date: Wed, 16 Mar 2016 20:07:02 -0400
Hi Axel,
Axel Dörfler wrote:
Hi Tim,
Am 16.03.2016 4:07 nachm. schrieb Tim Kelly <gtkelly@xxxxxxxxxxxxxxxxx>:
> I am still getting
>
> [ 586] _kern_reserve_address_range([0x200000], 0x1, 0x2e000) =
> 0x80000005 Invalid Argument (4 us)
You do notice that you see the actual return value of
_kern_reserve_address_range() here?
Not being familiar with strace or the Haiku architecture, no, I did not
initially realize that I was seeing the actual return value,
particularly since in the code it was embedded in an if statement with
no explicit return value.
Also, the value being returned (Invalid Argument) conflicts with what is
reported by runtime_loader (Out of memory), so I wasn't sure whom to
believe. Grepping on 0x80000005 doesn't actually return anything.
Invalid Argument and Out of memory correspond to
system/libroot/posix/string/strerror.c
error_description(int error)
{
switch (error) {
// General Errors
...
case B_NO_MEMORY:
case B_POSIX_ENOMEM:
// ENOMEM
return "Out of memory";
...
case B_BAD_VALUE:
// EINVAL
return "Invalid Argument";
B_BAD_VALUE is pieced together from
/system/develop/headers/os/support/Errors.h
#define B_GENERAL_ERROR_BASE INT_MIN
#define B_BAD_VALUE (B_GENERAL_ERROR_BASE + 5)
INT_MIN appears to be compiler-specific and is defined in
/system/develop/tools/lib/gcc-lib/i586-pc-haiku/2.95.3-haiku-2014_07_26/include/limits.h
as
/* Minimum and maximum values a `signed int' can hold. */
#ifndef __INT_MAX__
#define __INT_MAX__ 2147483647
#endif
#undef INT_MIN
#define INT_MIN (-INT_MAX-1)
#undef INT_MAX
#define INT_MAX __INT_MAX__
which means, if I understand correctly, errors can be positive or
negative, depending on the compiler. Since 0x80000000 is the most
negative 32-bit number (smallest != most negative), I was able to figure
out that 0x80000005 was the error being returned by
_kern_reserve_address_space, but the runtime_loader images.cpp code was
walking over it and returning B_NO_MEMORY (0x80000000) instead and the
actual error was occurring deep in the VM code.
So, no, I didn't realize I was seeing the actual return value. It took a
while. :-)
tim
--
"The Soviet media portrays the US political system as an oligarchy ruled
by big capitalists who control the impoverished masses."
-- CIA briefing to President Ronald Reagan
Other related posts: