Closed
Bug 160768
Opened 22 years ago
Closed 22 years ago
nsPipe2::ReadSegments goes into an infinite loop if writer returns NS_BASE_STREAM_WOULD_BLOCK and reads 0 bytes
Categories
(Core :: Networking, defect, P3)
Core
Networking
Tracking
()
RESOLVED
FIXED
mozilla1.3beta
People
(Reporter: bzbarsky, Assigned: darin.moz)
References
Details
(Keywords: topembed-)
If you look at http://lxr.mozilla.org/seamonkey/source/xpcom/io/nsPipe2.cpp#419 you can see that the return value of "writer" is explicitly checked against NS_BASE_STREAM_WOULD_BLOCK to prevent a goto to "done". Then "rv" is set to |pipe->mCondition|, which wipes out information on whether the writer func wanted to actaully get data or not. Then we loop forever, since no data is being consumed.
| Assignee | ||
Comment 1•22 years ago
|
||
nice find.. i'm not sure if we tickle this bug or not. yet, it may explain one of the infinite loops i saw with pipelining enabled.
| Reporter | ||
Comment 2•22 years ago
|
||
Note that http://lxr.mozilla.org/seamonkey/source/modules/libpr0n/src/imgRequest.cpp#766 (sniff_mimetype_callback) returns NS_ERROR_FAILURE; possibly to get around this problem....
| Assignee | ||
Comment 3•22 years ago
|
||
whoa, wrong milestone. not going to happen for mozilla 1.2.
Comment 4•22 years ago
|
||
do we have a reproducible test case that aggrivates this? if so, please re-nominate for "topembed"
| Reporter | ||
Comment 5•22 years ago
|
||
We have at least two ugly workarounds in Mozilla (in the nsUnicharStreamLoader and in imagelib) to handle the fact that the browser went into infinite loops because of this problem). The workarounds break the contract of the ReadSegments api to deal with this situation. Any embeddor attempting to use ReadSegments on an nsIPipe's input stream would run into this problem and curse the bugginess of the API (basically, the only way to get this API to work is to disregard the comments in the IDL and read the source to figure out the hackiness that needs to happen). So renominating.
| Assignee | ||
Comment 6•22 years ago
|
||
agreed.. fixing this bug requires rev'ing the documentation in nsIInputStream.idl and probably nsIOutputStream.idl.
Priority: P1 → P3
| Reporter | ||
Comment 7•22 years ago
|
||
Um you mean _not_ fixing this bug would require that, right?
| Assignee | ||
Comment 8•22 years ago
|
||
well, sort of... in addition to fixing the bug itself, i mean that the API for ReadSegments has a problem. if you call ReadSegments, and the segmentwriter decides to not write anything by returning NS_BASE_STREAM_WOULD_BLOCK, we cannot return WOULD_BLOCK from ReadSegments because that would imply that the pipe has no data in it when clearly it does. so what do we return? NS_ERROR_UNEXPECTED? or, NS_OK and zero bytes read? but, the latter means the stream has been closed :(
Comment 9•22 years ago
|
||
Boris, understood; thanks for the clarity. Still going to minus this one though as nsIPipe is not intended to be public (see http://www.mozilla.org/projects/embedding/apiReviewNotes.html#nsIPipe ).
| Assignee | ||
Comment 10•22 years ago
|
||
jud: but nsIStreamListener provides access to nsIInputStream, and the impl of that nsIInputStream could easily be a nsPipeInputStream.
| Assignee | ||
Updated•22 years ago
|
Target Milestone: mozilla1.3alpha → mozilla1.3beta
| Assignee | ||
Comment 11•22 years ago
|
||
this has been fixed with the patch for bug 176919.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•