Modify

Ticket #6200 (closed Patches: fixed)

Opened 2 years ago

Last modified 2 years ago

patch to have condition_variable and mutex error better handle EINTR

Reported by: blentz@… Owned by: viboes
Milestone: Boost 1.49.0 Component: thread
Version: Boost Development Trunk Severity: Problem
Keywords: 1.49 thread mutex eintr phusion passenger Cc: viboes

Description

On some flavors of Linux, for some versions of the pthread library, there are cases where it erroneously sends EINTR. This is a violation of POSIX, but it exists on some customer's production machines.

BOOST_VERIFY aborts on EINTR, but EINTR is usually not fatal, it just means you need to try later. Being that this behavior was found in production, I believe that it would be valuable to have Boost help protect downstream consumers from bad threading library behavior. This allows downstream consumers of Boost to not need to continuously rediscover and re-patch for this same bug.

So, with this in mind, attached is a proposed patch to allow condition_variable and mutex to better handle interacting with this potentially broken threading library behavior.

Attachments

thread_eintr.patch Download (2.7 KB) - added by blentz@… 2 years ago.
patch to correct for receiving EINTR in condition_variable and mutex.

Change History

Changed 2 years ago by blentz@…

patch to correct for receiving EINTR in condition_variable and mutex.

comment:1 Changed 2 years ago by viboes

  • Cc viboes added
  • Keywords 1.49 added
  • Status changed from new to assigned
  • Owner changed from anthonyw to viboes

This part is not correct

        55	res=pthread_cond_wait(&cond,&internal_mutex); 

 	55	int ret; 
 	56	do { 
 	57	  ret = pthread_cond_wait(&cond,m.mutex()->native_handle()); 
 	58	} while (ret == EINTR); 

Note that before the mutex used was internal_mutex. Are you sure that this patch is working for your applications?

comment:2 Changed 2 years ago by viboes

  • Milestone changed from To Be Determined to Boost 1.49.0

Committed in trunk revision [75781] condition variable part.

Last edited 11 months ago by viboes (previous) (diff)

comment:3 Changed 2 years ago by blentz@…

It looks like only the condition_variable and condition_variable_fwd portion of the patch was committed.

The changes to mutex are missing in revision 75781.

Was this done by choice or is it an oversight?

comment:4 Changed 2 years ago by viboes

Committed in trunk revision [75882] mutex part

Last edited 11 months ago by viboes (previous) (diff)

comment:5 Changed 2 years ago by viboes

  • Status changed from assigned to closed
  • Resolution set to fixed

Committed in release at [76291]

Last edited 11 months ago by viboes (previous) (diff)
View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.