[PATCHES][BUG 13170] Fix crash in pthreadpool thread after failure from pthread_create

Andreas Schneider asn at samba.org
Wed Dec 6 07:01:14 UTC 2017


On Tuesday, 5 December 2017 20:24:21 CET Christof Schmitt wrote:
> On Mon, Dec 04, 2017 at 01:33:20PM +0100, Andreas Schneider via samba-
technical wrote:
> > On Thursday, 30 November 2017 20:14:35 CET Christof Schmitt via samba-
> > 
> > technical wrote:
> > > On Thu, Nov 30, 2017 at 01:40:00PM +0100, Volker Lendecke wrote:
> > > > On Wed, Nov 29, 2017 at 12:23:34PM -0700, Christof Schmitt via samba-
> > 
> > technical wrote:
> > > > > As discussed in a side-thread, my initial patch lets the error
> > > > > surface
> > > > > back to the client. Here is an updated patch that avoids this issue.
> > > > > If
> > > > > no thread can be created, but another still exists, let that handle
> > > > > the
> > > > > request. If no thread exists, then fallback to processing the job
> > > > > synchronously, as the system might be hitting a resource limit.
> > > > 
> > > > From a review perspective, this looks good. For the refactoring one of
> > > > course RB+. However, pthreadpool being such a fragile piece of code I
> > > > would love to see unit tests for this.  This will require explicit
> > > > error injects with some DEVELOPER only code, but is it possible to get
> > > > this? If you don't have time, I might try to code something up.
> > > 
> > > Yes, see attached patch. I am not sure if that is the best solution, but
> > > it is easy enough. A more complicate approach would be LD_PRELOAD to
> > > overwrite the libc functions.
> > 
> > Use mocking support from cmocka to mock pthreadpool_create_thread()?
> > 
> > 
> > See https://lwn.net/Articles/558106/
> 
> Thanks for the pointer. Mocking the function completely does not work,
> as the good path requires creating an actual thread, but the --wrap
> option to override the call to pthread_create in the linker is useful.

Yes, that's what mocking is for. The test instruments how the mocked function 
behaves. So the test can tell the mocked function to call pthread_create() or 
return an error.


	Andreas

-- 
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at samba.org
www.samba.org



More information about the samba-technical mailing list