LTP testing
The next LTP failure line is:
pipe05 1 BROK : Unexpected signal 11 received.
For this one I haven't got a fix, because the failure is due to the way the pipe syscall is implemented for MIPS (so we need a fix in both the kernel and glibc).
The glibc code look like thisSYSCALL__ (pipe, 1)
/* Plop in the two descriptors. */
sw v0, 0(a0)
sw v1, 4(a0)
/* Go out with a clean status. */
move v0, zero
j ra
.end __pipeThe problem is that the code is called with $a0 = 0. So the 'sw v0, 0(a0)' after the syscall generates a segmentation fault. Why are the pipe syscall implemented this way, where we return the two descriptors in v0 and v1 ?
Why doesn't the kernel do these stores (this way we can do an access check, like i386 does) ?
/Carsten
--
_ _ ____ ___ Carsten Langgaard Mailto:[email protected] |\ /|||___)(___ MIPS Denmark Direct: +45 4486 5527 | \/ ||| ____) Lautrupvang 4B Switch: +45 4486 5555 TECHNOLOGIES 2750 Ballerup Fax...: +45 4486 5556 Denmark http://www.mips.com
Quoted 18 lines · Carsten Langgaard
The next LTP failure line is:
pipe05 1 BROK : Unexpected signal 11 received.For this one I haven't got a fix, because the failure is due to the way the pipe syscall is implemented for MIPS (so we need a fix in both the kernel and glibc).
The glibc code look like this
SYSCALL__(pipe, 1)/* Plop in the two descriptors. */ sw v0, 0(a0) sw v1, 4(a0) /* Go out with a clean status. */ move v0, zero j ra .end __pipe
Quoted 2 lines
The problem is that the code is called with $a0 = 0. So the 'sw v0, 0(a0)' after the syscall generates a segmentation fault.
The test is broken and it's what should be fixed, instead -- several
Linux platforms do it this way, e.g. Alpha and IA-64. A SIGSEGV is a valid response for an invalid address. Remember you test pipe(3) and not pipe(2).
Quoted 2 lines
Why are the pipe syscall implemented this way, where we return the two descriptors in v0 and v1 ?
For performance reasons. Also it's safer to do such actions from the
userland.
Quoted 2 lines
Why doesn't the kernel do these stores (this way we can do an access check, like i386 does) ?
I suppose i386 does these stores in the kernel due to historical reasons.
There is also the problem of a permanent lack of registers in i386 -- I haven't investigated it, but it may simply be unable to afford a second result register.
Signature · 3 lines
+ Maciej W. Rozycki, Technical University of Gdansk, Poland + +--------------------------------------------------------------+ + e-mail: [email protected], PGP key available +
Quoted 20 lines · Maciej W. Rozycki
Quoted 18 lines · Carsten Langgaard
The next LTP failure line is:
pipe05 1 BROK : Unexpected signal 11 received.For this one I haven't got a fix, because the failure is due to the way the pipe syscall is implemented for MIPS (so we need a fix in both the kernel and glibc).
The glibc code look like this
SYSCALL__(pipe, 1)/* Plop in the two descriptors. */ sw v0, 0(a0) sw v1, 4(a0) /* Go out with a clean status. */ move v0, zero j ra .end __pipe
Quoted 7 lines
Quoted 2 lines
The problem is that the code is called with $a0 = 0. So the 'sw v0, 0(a0)' after the syscall generates a segmentation fault.
The test is broken and it's what should be fixed, instead -- several
Linux platforms do it this way, e.g. Alpha and IA-64. A SIGSEGV is a valid response for an invalid address. Remember you test pipe(3) and not pipe(2).
I'm not sure that you mean by pipe(2) and pipe(3), but according to my man page, pipe should return with EFAULT in this case.
ERRORS
EMFILE Too many file descriptors are in use by the pro
cess.
ENFILE The system file table is full.
EFAULT filedes is not valid.
Quoted 17 lines
Quoted 4 lines
Why are the pipe syscall implemented this way, where we return the two descriptors in v0 and v1 ?
For performance reasons. Also it's safer to do such actions from the
userland.Quoted 2 lines
Why doesn't the kernel do these stores (this way we can do an access check, like i386 does) ?
I suppose i386 does these stores in the kernel due to historical reasons.
There is also the problem of a permanent lack of registers in i386 -- I haven't investigated it, but it may simply be unable to afford a second result register.--
Review
Quoted 3 lines
(quoted diff) +3
-0+ Maciej W. Rozycki, Technical University of Gdansk, Poland + +--------------------------------------------------------------+ + e-mail: [email protected], PGP key available +
--
_ _ ____ ___ Carsten Langgaard Mailto:[email protected] |\ /|||___)(___ MIPS Denmark Direct: +45 4486 5527 | \/ ||| ____) Lautrupvang 4B Switch: +45 4486 5555 TECHNOLOGIES 2750 Ballerup Fax...: +45 4486 5556 Denmark http://www.mips.com
Quoted 20 lines · Maciej W. Rozycki
Quoted 18 lines · Carsten Langgaard
The next LTP failure line is:
pipe05 1 BROK : Unexpected signal 11 received.For this one I haven't got a fix, because the failure is due to the way the pipe syscall is implemented for MIPS (so we need a fix in both the kernel and glibc).
The glibc code look like this
SYSCALL__(pipe, 1)/* Plop in the two descriptors. */ sw v0, 0(a0) sw v1, 4(a0) /* Go out with a clean status. */ move v0, zero j ra .end __pipe
Quoted 7 lines
Quoted 2 lines
The problem is that the code is called with $a0 = 0. So the 'sw v0, 0(a0)' after the syscall generates a segmentation fault.
The test is broken and it's what should be fixed, instead -- several
Linux platforms do it this way, e.g. Alpha and IA-64. A SIGSEGV is a valid response for an invalid address. Remember you test pipe(3) and not pipe(2).
The question is what API spec is relevant for Linux. My pipe(2) man page says (there is no pipe(3) man page):
int pipe(int filedes[2]);
...
ERRORS
...
EFAULT filedes is not valid.
whereas The Single UNIX ® Specification, Version 2
(http://www.opengroup.org/onlinepubs/007908799/xsh/pipe.html)
implies the SIGSEGV is OK.
Maybe the LTP folks can shed a light on this.
Regards,
Johannes
Quoted 6 lines · Carsten Langgaard
The problem is that the code is called with $a0 = 0. So the 'sw v0, 0(a0)' after the syscall generates a segmentation fault. Why are the pipe syscall implemented this way, where we return the two descriptors in v0 and v1 ?
Why doesn't the kernel do these stores (this way we can do an access check, like i386 does) ?
Because the interface we're using here is even lighter, even faster. Note that by the time when I decieded to use this interface this was potencially a huge difference as verify_area() was searching the mm AVL trees, so this interface was potenciall much faster by that time.
Ralf
Quoted 6 lines · Carsten Langgaard
Quoted 3 lines
Linux platforms do it this way, e.g. Alpha and IA-64. A SIGSEGV is a valid response for an invalid address. Remember you test pipe(3) and not pipe(2).
I'm not sure that you mean by pipe(2) and pipe(3), but according to my man page, pipe should return with EFAULT in this case.
pipe(2) is a syscall, while pipe(3) is a library call (see `man 2 intro'
and `man 3 intro', respectively). You rarely access syscalls directly -- the system library usually does this for you. Depending on a system certain library functions may be trivial syscall wrappers, invoke a number of syscalls (see e.g. the stat() family) or be implemented entirely in the userland.
Quoted 5 lines
ERRORS
EMFILE Too many file descriptors are in use by the pro
cess.
ENFILE The system file table is full.
EFAULT filedes is not valid.
Yep, this denotes such an error is possible and under what conditions. I
don't think it actually mandates it, at least it's not expressed explicitly. Anyway, it's valid for i386 and possibly nothing else. Look at the system version it refers to -- my version is: "Linux 0.99.11 23 July 1993".
A brief search of the web for "EFAULT pipe" reveals confirms others agree
with me -- the error is not mandatory (the EFAULT vs SIGSEGV issue was discussed a few times at least in various contexts -- go search the web).
I believe a SIGSEGV is saner, too -- this way it's harder for an error
resulting from passing an invalid pointer to remain unnoticed (consider some code that passes a pointer to read-only memory and fails to check a result of pipe()).
If still in doubt, you may try to discuss the LTP result at
<[email protected]>. I don't think anybody wants to rewrite pipe(2) for all the platforms that handle it our way.
Maciej
Signature · 3 lines
+ Maciej W. Rozycki, Technical University of Gdansk, Poland + +--------------------------------------------------------------+ + e-mail: [email protected], PGP key available +
Ok, you have convinced me, as long as the man page and the LTP get fixed.
/Carsten
Quoted 44 lines · Maciej W. Rozycki
Quoted 6 lines · Carsten Langgaard
Quoted 3 lines
Linux platforms do it this way, e.g. Alpha and IA-64. A SIGSEGV is a valid response for an invalid address. Remember you test pipe(3) and not pipe(2).
I'm not sure that you mean by pipe(2) and pipe(3), but according to my man page, pipe should return with EFAULT in this case.
pipe(2) is a syscall, while pipe(3) is a library call (see `man 2 intro'
and `man 3 intro', respectively). You rarely access syscalls directly -- the system library usually does this for you. Depending on a system certain library functions may be trivial syscall wrappers, invoke a number of syscalls (see e.g. thestat()family) or be implemented entirely in the userland.Quoted 5 lines
ERRORS
EMFILE Too many file descriptors are in use by the pro
cess.
ENFILE The system file table is full.
EFAULT filedes is not valid.Yep, this denotes such an error is possible and under what conditions. I
don't think it actually mandates it, at least it's not expressed explicitly. Anyway, it's valid for i386 and possibly nothing else. Look at the system version it refers to -- my version is: "Linux 0.99.11 23 July 1993".A brief search of the web for "EFAULT pipe" reveals confirms others agree
with me -- the error is not mandatory (the EFAULT vs SIGSEGV issue was discussed a few times at least in various contexts -- go search the web).I believe a SIGSEGV is saner, too -- this way it's harder for an error
resulting from passing an invalid pointer to remain unnoticed (consider some code that passes a pointer to read-only memory and fails to check a result ofpipe()).If still in doubt, you may try to discuss the LTP result at
<[email protected]>. I don't think anybody wants to rewrite pipe(2) for all the platforms that handle it our way.Maciej
--
Review
Quoted 3 lines
(quoted diff) +3
-0+ Maciej W. Rozycki, Technical University of Gdansk, Poland + +--------------------------------------------------------------+ + e-mail: [email protected], PGP key available +
--
_ _ ____ ___ Carsten Langgaard Mailto:[email protected] |\ /|||___)(___ MIPS Denmark Direct: +45 4486 5527 | \/ ||| ____) Lautrupvang 4B Switch: +45 4486 5555 TECHNOLOGIES 2750 Ballerup Fax...: +45 4486 5556 Denmark http://www.mips.com
Quoted 1 line · Carsten Langgaard
Ok, you have convinced me, as long as the man page and the LTP get fixed.
Linux man pages traditionally are just a rough approximation; the official X-Open, SysV ABI etc. standards documents should be consulted instead.
Ralf