Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

multiprocessing.connection.Client deadlocks when trying to connect to a listener without a password #123736

Open
Labels
@MarcinKonowalczyk

Description

@MarcinKonowalczyk

Bug report

Bug description:

We set up a multiprocessing.connection.Listener with no authkey. When we try to connect to it with a Clientwith an authkey, the Client deadlocks. Here is a working example:

importsocketimportthreadingimporttimefrommultiprocessing.connectionimportClient,Listenerdef_test(*,listener:str|None,client:str|None)->tuple[Exception|None,Exception|None,list]:_autkey_listener=listener.encode()iflistenerelseNone_authkey_client=client.encode()ifclientelseNonewithsocket.socket(socket.AF_INET,socket.SOCK_STREAM)ass:s.bind(("localhost",0))address=s.getsockname()thread_exc=Nonethread_got= []client_exc=Nonedeftarget()->None:try:withListener(address,authkey=_autkey_listener)asl:c=l.accept()whileTrue:value=c.recv()ifnotvalue:breakthread_got.append(value)exceptExceptionase:nonlocalthread_excthread_exc=et=threading.Thread(target=target)t.start()try:withClient(address,authkey=_authkey_client)asc:c.send("hello")time.sleep(0.1)c.send(None)t.join()exceptExceptionase:client_exc=ereturnthread_exc,client_exc,thread_gotif__name__=="__main__":print(" no passwords ".center(40,"-"))print(_test(listener=None,client=None))print(" two matching passwords ".center(40,"-"))print(_test(listener="password",client="password"))print(" client has wrong password ".center(40,"-"))print(_test(listener="password",client="wrong"))print(" client has no password ".center(40,"-"))print(_test(listener="password",client=None))# This is the case which deadlocksprint(" listener has no password ".center(40,"-"))print(_test(listener=None,client="password"))

which outputs:

------------- no passwords -------------(None, None, ['hello'])-------- two matching passwords --------(None, None, ['hello'])------ client has wrong password -------(AuthenticationError('digest received was wrong'), AuthenticationError('digest sent was rejected'), [])-------- client has no password --------(AuthenticationError("expected 'md5' of length 16 got 20"), None, [])------- listener has no password -------

and then stops.

Upon some investigation, the following bit of code fromClient is to blame:

ifauthkeyisnotNone:answer_challenge(c,authkey)deliver_challenge(c,authkey)

since the listener is not configured to deliver the challenge to the connections. I think this would be resolved with an optional timeout kwarg inanswer_challenge. If this suggestion is accepted I would be very happy to work on it 👍

CPython versions tested on:

3.9, 3.10, 3.11, 3.12

Operating systems tested on:

macOS, Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp