[PATCH v3] lib/eal: fix segfaults due to thread exit order

Zeng, ZhichaoX zhichaox.zeng at intel.com
Thu Jun 2 10:21:19 CEST 2022


Hi Stephen:

> -----Original Message-----
> From: Stephen Hemminger <stephen at networkplumber.org> 
> Sent: Tuesday, May 31, 2022 12:29 AM
> To: Zeng, ZhichaoX <zhichaox.zeng at intel.com>
> Cc: dev at dpdk.org; Yang, Qiming <qiming.yang at intel.com>; Richardson, Bruce <bruce.richardson at intel.com>; hkalra at marvell.com; david.marchand at redhat.com; aconole at redhat.com; Matz, Olivier > > <olivier.matz at 6wind.com>; thomas at monjalon.net; stable at dpdk.org
> Subject: Re: [PATCH v3] lib/eal: fix segfaults due to thread exit order
>
> On Mon, 30 May 2022 13:47:38 +0000
> zhichaox.zeng at intel.com wrote:

> > @@ -883,6 +896,8 @@ rte_eal_init(int argc, char **argv)
> >  
> >  	eal_mcfg_complete();
> >  
> > +	pthread_atfork(NULL, warn_parent, scratch_child);
> > +
> >  	return fctret;
> >  }

> There are lots of other cases where DPDK will die if you fork() in a DPDK process then call DPDK functions in child. 

> Not sure what the problem you are trying to solve is?

The original goal of this patch was to cancel eal-intr-thread before memory cleanup to avoid a small probability of segfaults. 

But in the debug_autotest test of dpdk-test, fork() is called and the exit process is tested in the child process which will call the rte_eal_cleanup function and mistakenly clean up non-existing threads. This will cause segmentation fault. 

Based on patch v2, atomic operation is added to determine whether it is a child process, so that the cleaning process will not execute in the child process to avoid the above problem.

Regards


More information about the dev mailing list