Opened 16 years ago

Closed 16 years ago

#51 closed defect (fixed)

pipes not created unique

Reported by: diver Owned by: dmik
Priority: normal Milestone:
Component: kernel Version:
Severity: normal Keywords:
Cc:

Description

in qprocess_pm.cpp it's possible that pipes are not created unique. this leads to a problem if a new process is started with the same pipe key. the problem occured in smplayer.

see attached patch to qprocess_pm.cpp. it fixes the smplayer problem

Attachments (2)

patch.txt (1.4 KB ) - added by diver 16 years ago.
out1.txt (7.3 KB ) - added by diver 16 years ago.

Download all attachments as: .zip

Change History (12)

by diver, 16 years ago

Attachment: patch.txt added

comment:1 by dmik, 16 years ago

Status: newassigned

Good catch, Silvan! Indeed, due to the delayed processing of the WM_I_PIPE_CLOSE message, it was possible that the pipe key would already refer to foreign pipe from another process started in the meantime.

However, the workaround you suggest has a small flaw: consider what happens if an application starts an ever running process that gets a pipe key equal to 1 and then starts many short-term processes that eventually cause the key to wrap over USHORT... It's rare but IMHO still quite possible for a long running application.

Instead, in r186, I attempted to fix the real problem -- by making sure the key is not used after the associated pipe is closed. Please check that it really works with smplayer and report here.

P.S. To say the all truth, the original idea of using the 32-bit pipe handle as a 16-bit key also has a potential flaw (the system may return a handle that uses more than low 16 bits) but the side effect will be less dramatic: Qt will simply refuse to start a process and return a failure from QProcess::start(). Anyway, if it ever happens, the proper solution is to use QFreeValueList from qeventloop_pm.cpp for managing unique key values for pipes.

comment:2 by diver, 16 years ago

Dmik, i built a new qt dll and sent it to the person who discovered the orginal bug. according to him the new dll shows the same behaviour as the one from svn rev 185. The problem only occurs if one plays from a playlist in smplayer.the problem is an assertion, but it leads to a hang. most probably because mplayer writes to a pipe which does not exist anymore.

comment:3 by diver, 16 years ago

this message is issued and after that mplayer dies Warning: ASSERT: "pipe->closed" in kernel/qprocess_pm.cpp (596)

this happens when the second mplayer was started from the playlist. could it be that a message was not cleared from the object window?

comment:4 by dmik, 16 years ago

Ok, next question. Can you reproduce it yourself with process debugging enabled? We really should find out why exactly this happens.

comment:5 by diver, 16 years ago

sure i can. i will build a new dll with process debugging enabled and attach the log here.

by diver, 16 years ago

Attachment: out1.txt added

comment:6 by diver, 16 years ago

in out1.tyt you see the ending of the first movie in the playlist. and the start of the next with the assert problem

comment:7 by dmik, 16 years ago

We were missing some pipe close points in other places too. In r188, I attempted to fix the problem once more -- this time by processing all associated messages from the queue before closing the pipes.

comment:8 by diver, 16 years ago

i did some limited testing and it seems to work. i sent the new dll to some other testers and if it works there also i will close the ticket

comment:9 by diver, 16 years ago

this fix works like a charm. so the ticket can be closed

comment:10 by dmik, 16 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.