On Fri, Nov 30, 2012 at 12:24 PM, NuSkooler <nuskoo...@gmail.com> wrote:
> I think responses like this would be much more helpful without the FUD.
I have no fear since I don't suffer uncertainty. The macros are broken.

> WaitForSingleObject() and WaitForMultipleObjects() return WAIT_ABANDONED if
> the mutex has been closed. WAIT_OBJECT_0 would only be expected if you
> didn't read the documentation.
Bullshit. Write some negative tests and see what you get back. You
will get everything from WAIT_FAILED to ERROR_INVALID_HANDLE.

> I suggest you both do so before utilizing
> these functions.

> Also, I'm not aware of any such race conditions in Boost. Perhaps in very
> old versions, but the threading library is solid. Again, you probably want
> to read the documentation before utilizing.
OK. Here's a list of report numbers I filed against them last year
when I was auditing Boost for inclusion in another project: 5826,
5827, 5829, 5830, 5831, 5833, 5834, 5835, 5836, 5837, 5838, 5839,
5840, 5841, 5842, 5843, 5844, and 5845. I uploaded an image for you:
http://img829.imageshack.us/img829/5563/boostreport.jpg.

I would be happy to reject your code too if you are practicing the
same sloppy programming techniques. I don't discriminate.

Jeff

> On Fri, Nov 30, 2012 at 9:03 AM, Jeffrey Walton <noloa...@gmail.com> wrote:
>>
>> On Thu, Nov 29, 2012 at 9:57 AM, Staneva, Yana <ysten...@micros.com>
>> wrote:
>> > #define  MUTEX_TYPE        HANDLE
>> >
>> > #define  MUTEX_SETUP(x)    (x) = CreateMutex( NULL, FALSE, NULL )
>> >
>> > #define  MUTEX_CLEANUP(x)  CloseHandle(x)
>> >
>> > #define  MUTEX_LOCK(x)     WaitForSingleObject( (x), INFINITE )
>> >
>> > #define  MUTEX_UNLOCK(x)   ReleaseMutex(x)
>> >
>> > #define  THREAD_ID         GetCurrentThreadId()
>> Don't use these macros. On Windows, you must check return values
>> (that's non-negotiable). WaitForSingleObject is especially egregious
>> because it could lead to corruption. For example, if you accidentally
>> close the Mutex, WaitForSingleObject will return ERROR_INVALID_HANDLE
>> rather than the expected WAIT_OBJECT_0.
>>
>> Boost is another offender. It ignores return values and suffer races
>> in its threading gear. Be very careful if you are using that library
>> on Windows.
>>
>> I can't explain all the defective code circulating. Folks must all be
>> copy/paste'ing the same junky code.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to