[PATCH v5] lib/eal: fix segfaults in exiting
Zeng, ZhichaoX
zhichaox.zeng at intel.com
Wed Sep 7 10:53:38 CEST 2022
Hi Stephen,
> >
> > +static void mark_forked(void)
> > +{
> > + is_forked++;
> > +}
> > +
>
> This will end up counting application threads as well.
>
I think it would be counted in the child process when 'fork()' is called,
and in the parent process, it would be zero.
> Also, it would need to be atomic.
>
Thanks for your advice.
> > /* Launch threads, called at application init(). */ int
> > rte_eal_init(int argc, char **argv) @@ -1324,6 +1331,8 @@
> > rte_eal_init(int argc, char **argv)
> >
> > eal_mcfg_complete();
> >
> > + pthread_atfork(NULL, NULL, mark_forked);
> > +
> > return fctret;
> > }
>
> > int
> > rte_eal_cleanup(void)
> > {
> > + if (is_forked)
> > + return 0;
> > +
>
> rte_eal_cleanup is supposed to be called only once by application.
Yes. But in some case(e.g. debug_autotest of dpdk-test), it would fork
a child process to test 'rte_exit()', then it would call 'rte_eal_cleanup()'.
So 'is_forked' is introduced to avoid this situation.
Regards
Zhichao
More information about the stable
mailing list