+
    Bi	1                        ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
 ^ RIHtHt ^ RIHt ^RIHtHtHtHtHt RR ltR tR	 tR
 tR tR t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t  ! R R]4      t! ! R R]4      t" ! R R4      t#]! ]$! 4       ]#]]]3R7       R t%]&R8X  d   ]PN                  ! 4        R# R# )    NPicklingError)futures)BrokenProcessPool_ThreadWakeup)support)create_executor_testssetup_moduleProcessPoolForkMixinProcessPoolForkserverMixinProcessPoolSpawnMixinc                    V '       d   \         P                  ! V 4       ^ RIpVP                  4        VP	                  4        R# )zInduces a segfault.N)timesleepfaulthandlerdisable_sigsegv)delayr   s   & A/usr/lib/python3.14/test/test_concurrent_futures/test_deadlock.py_crashr      s,    

5    c                    \        4        R# )z,Induces a segfault with dummy data in input.Nr   )datas   &r   _crash_with_datar      s    
Hr   c                 2    \         P                  ! ^4       R# )z#Induces a sys exit with exitcode 1.N)sysexit r   r   _exitr    !   s    HHQKr   c                    V ! 4       h)z-Function that raises an Exception in process.r   )Errs   &r   _raise_errorr#   &   s	    
%Kr   c                J    ^ RI pVP                  4       \        n        V ! 4       h)z@Function that raises an Exception in process and ignores stderr.N)ioStringIOr   stderr)r"   r%   s   & r   _raise_error_ignore_stderrr(   +   s    CJ
%Kr   c                    V ! 4       # )z(Function that returns a instance of cls.r   )clss   &r   _return_instancer+   2   s	    5Lr   c                   *   a  ] tR t^7t o RtR tRtV tR# )CrashAtPicklez5Bad object that triggers a segfault at pickling time.c                    \        4        R # Nr   selfs   &r   
__reduce__CrashAtPickle.__reduce__9   s    r   r   N__name__
__module____qualname____firstlineno____doc__r2   __static_attributes____classdictcell____classdict__s   @r   r-   r-   7   s     ? r   r-   c                   *   a  ] tR t^=t o RtR tRtV tR# )CrashAtUnpicklez7Bad object that triggers a segfault at unpickling time.c                    \         R3# Nr   r   r0   s   &r   r2   CrashAtUnpickle.__reduce__?   s    rzr   r   Nr4   r<   s   @r   r?   r?   =   s     A r   r?   c                   *   a  ] tR t^Ct o RtR tRtV tR# )ExitAtPicklez9Bad object that triggers a process exit at pickling time.c                    \        4        R # r/   r    r0   s   &r   r2   ExitAtPickle.__reduce__E   s    r   r   Nr4   r<   s   @r   rD   rD   C   s     C r   rD   c                   *   a  ] tR t^It o RtR tRtV tR# )ExitAtUnpicklez;Bad object that triggers a process exit at unpickling time.c                    \         R3# rA   rF   r0   s   &r   r2   ExitAtUnpickle.__reduce__K   s    byr   r   Nr4   r<   s   @r   rI   rI   I   s     E r   rI   c                   *   a  ] tR t^Ot o RtR tRtV tR# )ErrorAtPicklez3Bad object that triggers an error at pickling time.c                    ^ RI Hp V! R4      h)r   r   zError in pickle)pickler   )r1   r   s   & r   r2   ErrorAtPickle.__reduce__Q   s    (-..r   r   Nr4   r<   s   @r   rM   rM   O   s     =/ /r   rM   c                   *   a  ] tR t^Vt o RtR tRtV tR# )ErrorAtUnpicklez5Bad object that triggers an error at unpickling time.c                     ^ RI Hp \        V33# )r   )UnpicklingError)rO   rT   r(   )r1   rT   s   & r   r2   ErrorAtUnpickle.__reduce__X   s    *)O+>>>r   r   Nr4   r<   s   @r   rR   rR   V   s     ?? ?r   rR   c                     a  ] tR t^]t o ]P
                  tR tRR/R ltR t	R t
R t]P                  ! RR	R
7      R 4       t]P                  ! RR	R
7      R 4       tR tR t]P                  ! RR	R
7      R 4       tR tR tR tR t]P                  ! RR	R
7      R 4       tR t]P                  ! RR	R
7      R 4       tR tRtV tR# )ExecutorDeadlockTestc                   ^ RI p^ RIHp V! RR7      ;_uu_ 4       pVP                  VR7       VP	                  ^ 4       VP                  4       pRRR4       VP                  P                  4        F  pVP                  4        K  	  VP                  RR7       \        RX 2\        P                  R7       V P                  R	V 24       R#   + '       g   i     L; i)
r   N)TemporaryFilezw+)mode)fileTwaitz
Traceback:
 zExecutor deadlock:

)r   tempfilerY   dump_tracebackseekread
_processesvalues	terminateshutdownprintr   
__stderr__fail)r1   executorr   rY   ftbps   &&     r   _fail_on_deadlock&ExecutorDeadlockTest._fail_on_deadlock`   s     	*%%''Q'/FF1IB & $$++-AKKM . 	t$t$3>>:		*2$/0 &%s   4CC	ignore_stderrFc          	     z   V P                   P                  R R7       V P                  ^V P                  4       R7      pVP                  ! V.VO5!  pV'       d   \
        P                  ! 4       pM\        P                  ! 4       p V P                  V4      ;_uu_ 4        V;_uu_ 4        VP                  V P                  R7       RRR4       RRR4       TP                  R R7       R#   + '       g   i     L,; i  + '       g   i     L7; i  \        P                   d    T P                  T4        Lbi ; i)Tr\   max_workers
mp_context)timeoutN)ri   re   executor_typeget_contextsubmitr   captured_stderr
contextlibnullcontextassertRaisesresultTIMEOUTr   TimeoutErrorrm   )r1   errorfuncro   argsri   rescms   &&&$*   r   _check_error!ExecutorDeadlockTest._check_errorr   s    D)%%d&6&6&8 & :ood*T*((*B'')B	-""5))RJJt||J4  * 	t$ R *) ## 	- ""8,	-sH   D C>*C+	C>D +C;6C>>D		D D &D:9D:c                L    V P                  \        \        \        4       4       R # r/   )r   r   idrM   r0   s   &r   test_error_at_task_pickle.ExecutorDeadlockTest.test_error_at_task_pickle   s     	-]_=r   c                L    V P                  \        \        \        4       4       R # r/   )r   r   r   rI   r0   s   &r   test_exit_at_task_unpickle/ExecutorDeadlockTest.test_exit_at_task_unpickle   s    +R1ABr   c                    V P                  \        \        R \        P                  4       V P	                  \
        \        \        4       4       R# )r'   N)
addCleanupsetattrr   r'   r   r   r   rR   r0   s   &r   test_error_at_task_unpickle0ExecutorDeadlockTest.test_error_at_task_unpickle   s0    h

; 	+R1BCr   z"UBSan: explicit SIGSEV not allowedT)ubc                L    V P                  \        \        \        4       4       R # r/   )r   r   r   r?   r0   s   &r   test_crash_at_task_unpickle0ExecutorDeadlockTest.test_crash_at_task_unpickle   s     	+R1BCr   c                :    V P                  \        \        4       R # r/   )r   r   r   r0   s   &r   %test_crash_during_func_exec_on_worker:ExecutorDeadlockTest.test_crash_during_func_exec_on_worker   s     	+V4r   c                :    V P                  \        \        4       R # r/   )r   
SystemExitr    r0   s   &r   $test_exit_during_func_exec_on_worker9ExecutorDeadlockTest.test_exit_during_func_exec_on_worker   s    *e,r   c                D    V P                  \        \        \        4       R # r/   )r   RuntimeErrorr#   r0   s   &r   %test_error_during_func_exec_on_worker:ExecutorDeadlockTest.test_error_during_func_exec_on_worker   s    ,lCr   c                D    V P                  \        \        \        4       R # r/   )r   r   r+   r-   r0   s   &r   )test_crash_during_result_pickle_on_worker>ExecutorDeadlockTest.test_crash_during_result_pickle_on_worker   s     	+-=}Mr   c                D    V P                  \        \        \        4       R # r/   )r   r   r+   rD   r0   s   &r   (test_exit_during_result_pickle_on_worker=ExecutorDeadlockTest.test_exit_during_result_pickle_on_worker   s     	*&6Er   c                D    V P                  \        \        \        4       R # r/   )r   r   r+   rM   r0   s   &r   )test_error_during_result_pickle_on_worker>ExecutorDeadlockTest.test_error_during_result_pickle_on_worker   s     	-)9=Ir   c                    V P                  \        \        R \        P                  4       V P	                  \
        \        \        RR7       R# )r'   T)ro   N)r   r   r   r'   r   r   r+   rR   r0   s   &r   3test_error_during_result_unpickle_in_result_handlerHExecutorDeadlockTest.test_error_during_result_unpickle_in_result_handler   s8    h

; 	+*O(, 	 	.r   c                D    V P                  \        \        \        4       R # r/   )r   r   r+   rI   r0   s   &r   2test_exit_during_result_unpickle_in_result_handlerGExecutorDeadlockTest.test_exit_during_result_unpickle_in_result_handler   s     	+-=~Nr   c           	        V P                   P                  R R7       V P                  ^V P                  4       R7      ;_uu_ 4       pWn         VP	                  \
        RR7      pVP                  R R7       V P                  \        4      ;_uu_ 4        VP                  4        RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)Tr\   rq   g?)r   N)	ri   re   ru   rv   rw   r   r{   r   r|   )r1   ri   rj   s   &  r   test_shutdown_deadlock+ExecutorDeadlockTest.test_shutdown_deadlock   s     	D)A+/+;+;+=   ? ?BJ$Mb1A4(""#455
 6? ?
 65? ? ?s%   AC	B6	$C	6CC		C	c           	     F   V P                   P                  R R7       V P                  ^V P                  4       R7      ;_uu_ 4       pWn         VP	                  \
        ^*4      P                  4        VP                  pVP	                  \
        \        4       4      pVP                  RR7       V P                  \        4      ;_uu_ 4        VP                  4        RRR4       RRR4       XP                  4        R#   + '       g   i     L*; i  + '       g   i     L5; i)Tr\   rq   FN)ri   re   ru   rv   rw   r   r|   _executor_manager_threadrM   r{   r   join)r1   ri   executor_managerrj   s   &   r   test_shutdown_deadlock_pickle2ExecutorDeadlockTest.test_shutdown_deadlock_pickle   s     	D)A+/+;+;+=   ? ?BJ$M
 OOB#**,'@@ MO4A5)""=11
 2?& 	 21? ?s%   BD
C=	D=DDD 	c                   V P                   P                  R R7       R\        P                  ,          pV P	                  ^V P                  4       R7      ;_uu_ 4       pW n         V P                  \        4      ;_uu_ 4        \        VP                  \        V.^
,          4      4       RRR4       RRR4       XP                  R R7       R#   + '       g   i     L,; i  + '       g   i     L7; i)Tr\   arq   N)ri   re   r   PIPE_MAX_SIZEru   rv   r{   r   listmapr   )r1   r   ri   s   &  r   test_crash_big_data(ExecutorDeadlockTest.test_crash_big_data   s     	D)W***A+/+;+;+=   ? ?BJ$M""#455X\\"2TFRK@A 6? 	t$ 65? ?s$   $C (C	)C CC  C0	c                  a V P                   P                  R R7       \        \        R4      '       g   \        P
                  ! R4      hR p\        P                  P                  P                  oV3R lp ! R R\        4      p\        P                  P                  P                  \        P                  P                  RV4      ;_uu_ 4        \        P                  P                  R	V4      ;_uu_ 4        V P                  ^V P                  4       R
7      ;_uu_ 4       pW@n         ^dp\!        V4      p\        P                  ! \        P"                  V4      p \        P$                  ! \'        V P(                  4      4       V P+                  V\-        \/        VP1                  \&        V4      4      4      4       \        P$                  ! ^ 4       \        P                  ! \        P"                  V4        RRR4       RRR4       RRR4       R#   \        P$                  ! ^ 4       \        P                  ! \        P"                  T4       i ; i  + '       g   i     Lb; i  + '       g   i     Lm; i  + '       g   i     R# ; i)Tr\   alarmz1Tested platform does not support the alarm signalc                 @    ^ RI pVP                  4        \        R4      h)r   Nz timed out while submitting jobs?)r   r_   r   )_signum_framer   s   && r   rt   [ExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.timeout  s    '')ABBr   c                 D   < \         P                  ! ^4       S! V 4       R# )   N)r   r   )r1   
thread_runs   &r   mock_run\ExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.mock_run  s    JJqMtr   c                   N   a a ] tR tRt oRtV 3R ltV 3R ltV 3R ltRtVt	V ;t
# )^ExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.MockWakeupi  z/Mock wakeup object to force the wakeup to blockc                \   < \         SV `  4        \        P                  ! ^R7      V n        R# )   )maxsizeN)super__init__queueQueue_dummy_queuer1   	__class__s   &r   r   gExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.MockWakeup.__init__  s     "$)KK$:!r   c                ^   < V P                   P                  R RR7       \        SV `  4        R # )NT)block)r   putr   wakeupr   s   &r   r   eExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.MockWakeup.wakeup   s&    !!%%d$%7 r   c                   < \         SV `  4          V P                  P                  4        K    \        P
                   d     R# i ; i)TN)r   clearr   
get_nowaitr   Emptyr   s   &r   r   dExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full.<locals>.MockWakeup.clear$  s<    ))446{{ s   . AA)r   )r5   r6   r7   r8   r9   r   r   r   r:   r;   __classcell__)r   r=   s   @@r   
MockWakeupr     s     A;! r   r   runz(concurrent.futures.process._ThreadWakeuprq   N)ri   re   hasattrsignalunittestSkipTestr   process_ExecutorManagerThreadr   r   mockpatchobjectru   rv   rangeSIGALRMr   intr}   assertEquallenr   r   )	r1   rt   r   r   ri   job_numjob_dataold_handlerr   s	   &       @r   5test_gh105829_should_not_deadlock_if_wakeup_pipe_fullJExecutorDeadlockTest.test_gh105829_should_not_deadlock_if_wakeup_pipe_full  s    	D)vw''##CE E	C __;;??
	
	 	$ mm!!(()O)O).: :mm!!"L",. .##/3/?/?/A $ C CFN ( > %mmFNNGD?LLT\\!23$$Wc$x||C7R2S.TULLOMM&..+>'C.: :, LLOMM&..+>'C C. .: : :sU   )I;:*I(	$9IA!H?;I;I(	I;=III% I(	(I83I;;J	)ri   N)r5   r6   r7   r8   r   LONG_TIMEOUTr}   rm   r   r   r   r   skip_if_sanitizerr   r   r   r   r   r   r   r   r   r   r   r   r   r:   r;   r<   s   @r   rW   rW   ]   s    ""G1$%U %.>
CD CMD ND CM5 N5-D CMN NN
F
J
.O
 CM
 N
 4 CM% N%B? B?r   rW   )executor_mixinsc                      \        4        R # r/   )r
   r   r   r   setUpModuler   K  s    Nr   __main__r/   )(ry   r   r   r   r   r   unittest.mockrO   r   
concurrentr   concurrent.futures.processr   r   testr   utilr	   r
   r   r   r   r   r   r    r#   r(   r+   r   r-   r?   rD   rI   rM   rR   rW   globalsr   r5   mainr   r   r   <module>r     s       
       G M M




F f 6 V /F /?f ?f? f?R gi!5';'A'<'>?
 zMMO r   