stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <>
Subject Re: [PATCH] Update test to validate results
Date Fri, 10 Aug 2007 20:42:15 GMT
Travis Vitek wrote:

> Martin Sebor wrote:
>>We can't be using rw_assert() in a thread function (the driver
>>isn't thread safe yet, and if it was it would unnecessarily
>>synchronize the threads). Use the RW_ASSERT() macro instead.
> I think there will be a lot of useful context that is lost if
> I switch to RW_ASSERT. It would be especially useful to know
> the active locale, the input value, and the output values in
> these test cases.

These values are invaluable when the tests fail due to a problem
other than a thread safety bug in the library but I'm not sure
they would be of much use in the case of a thread safety bug
that manifests itself by corrupting data. Do you have specific
scenario in mind where this information would be useful?

> I'm thinking of doing something like this in each of the facet
> tests.
> _RW::__rw_synchronized __driver_syncronize;

This would introduce a dependency of the test on the correct
behavior of component that is being tested. To do something like
this we'd need to introduce a separate synchronization mechanism
into the test driver. But I'm not sure that'll be necessary. I'd
rather avoid any kind of synchronization in the thread function.
If you do want to make this information available, I suggest
returning it from the thread function to the main thread in the
form of indices into the data array and having the main thread
display it in a call to rw_fatal(). Even so, I'd only make this
behavior available under an option and leave it disabled by
default. Once there's a thread safety bug, especially one that
corrupts data, the behavior of the whole program is undefined
and so we can't really trust anything, except the simplest
mechanisms such as assert()/abort().


> #define rw_mt_safe_diag(fn, expr, args)                     \
>     if (!(expr)) {                                          \
>         __rw_guard guard (__driver_syncronize._C_guard ()); \
>         fn args;                                            \
>     }
> In the test threads I would use it like this...
>   rw_mt_safe_diag (rw_warn, !rw_strncmp(buf, expected),
>                    (0, 0, 0, "num_put<%s>::put(..., %s (%d)) "
>                     "did not match expected for locale(%#s). "
>                     "expected %#s but got %#s.",
>                     #charT, #valueT, val, loc, expect, buf));
> I realize that this doesn't make the entire driver thread safe,
> but it does serialize access to everything that the threads are
> doing with the driver, and only when necessary.
> What do you think?
> Travis

View raw message