Opened 16 years ago
Last modified 4 years ago
#3353 assigned enhancement
resource.h broken (not implemented yet?)
Reported by: | scottmc | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | R1.1 |
Component: | System/POSIX | Version: | R1/pre-alpha1 |
Keywords: | Cc: | ||
Blocked By: | #7556, #14749 | Blocking: | |
Platform: | All |
Description
May be related to ticket #2817 perhaps not, python's test_resource.py passes the first test, then fails the next 3 and then crashes on getrusage.
~/develop/python/Lib/test> python test_resource.py test_args (__main__.ResourceTest) ... ok test_fsize_enforced (__main__.ResourceTest) ... ERROR test_fsize_ismax (__main__.ResourceTest) ... ERROR test_fsize_toobig (__main__.ResourceTest) ... ERROR test_getrusage (__main__.ResourceTest) ... Kill Thread ~/develop/python/Lib/test>
Attachments (1)
Change History (22)
comment:2 by , 10 years ago
Apparently only part of POSIX spec for [gs]et_rlimit is implemented, and when it encounters an unimplemented property it just returns EINVAL.
I'm not sure what the right thing to do is here. Should I make it return ENOSYS instead? But that would break a lot of apps relying on POSIX. Or I could make it return 0 as the values.
List of unimplemented properties:
RLIMIT_CPU
: maximum amount of CPU time, in seconds, used by a processRLIMIT_DATA
: maximum size of a process' data segment, in bytesRLIMIT_FSIZE
: maximum size of a file, in bytes, that may be created by a processRLIMIT_STACK
(implemented inget_rlimit()
but not inset
): maximum size of the initial thread's stack, in bytesRLIMIT_AS
: maximum size of a process' total available memory, in bytes
I will investigate the getrusage()
failure soon.
comment:3 by , 10 years ago
The getrusage()
function itself works fairly well, from my standalone test program. I believe the issue is in one of the patches applied to get python to build, as the segfault seems to be from the python internals. I will try to confirm.
comment:4 by , 10 years ago
Interestingly, the getrusage()
issue only seems to be reproducible on x86_gcc2. x86_64 does not have this issue. I will test pure x86 soon.
comment:5 by , 10 years ago
My program used to test getrusage()
:
#include <errno.h> #include <stdio.h> #include <sys/resource.h> // From https://github.com/python/cpython/blob/2.7/Modules/resource.c#L20 #define doubletime(TV) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001) int main() { struct rusage ru = {0}; int ret; ret = getrusage(RUSAGE_SELF, &ru); printf("%d %d %f %f\n", ret, errno, doubletime(ru.ru_utime), doubletime(ru.ru_stime)); return ret; }
It prints something like this:
0 0 0.1034 0.1620
The first two 0's indicate that there is no error (ret
and errno
resp.).
comment:7 by , 10 years ago
Hah found where the issue is. It is in a patch in Python. Will submit a PR to haikuports soon.
follow-up: 9 comment:8 by , 10 years ago
Please include a link to your PR so we can check and close this. Thanks for investigating!
comment:9 by , 10 years ago
Replying to pulkomandy:
Please include a link to your PR so we can check and close this. Thanks for investigating!
Here: https://bitbucket.org/haikuports/haikuports/pull-request/453/fix-python-resource-module/diff
comment:10 by , 10 years ago
Type: | bug → enhancement |
---|
Ok, PR is merged. It would still be nice to actually implement things so we don't have to hack around it in Python sources, but at least the crash is fixed now.
comment:11 by , 8 years ago
Component: | - General → System/POSIX |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:12 by , 7 years ago
Added RLIMIT_AS, RLIMIT_DATA, and RLIMIT_STACK for setrlimit() to match getrlimit(). Please see the attached patch.
by , 7 years ago
Attachment: | 0002-Implement-setrlimit-for-RLIMIT_AS-RLIMIT_DATA-and-RL.patch added |
---|
comment:13 by , 7 years ago
patch: | 0 → 1 |
---|
comment:14 by , 7 years ago
I don't think this is the right way to go about it. Either we don't support changing the values, and we always return EINVAL (this is what happens now). Or, we do support setting them, and by this I mean also setting them to a value other than the default.
With your changes, the function now returns "ok" in some cases, which makes it harder to check wether actually changing the value is possible, but no functionality is gained. This is not of much use.
comment:15 by , 7 years ago
Because the existing code doesn't support RLIMIT_CORE and doesn't always return EINVAL in common_setrlimit
, I made the other rlimits to match the behavior. So the current way of handling RLIMIT_CORE in common_setrlimit
is also wrong?
comment:16 by , 7 years ago
patch: | 1 → 0 |
---|
comment:18 by , 6 years ago
Blocked By: | 7556 added |
---|
comment:19 by , 6 years ago
Blocked By: | 14749 added |
---|
comment:20 by , 5 years ago
Checked with POSIX.1-2017 spec. PASSES.
comment:21 by , 4 years ago
Milestone: | R1 → R1.1 |
---|
The first three errors are easily reproducible with