View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006197 | Taler | exchange | public | 2020-04-22 12:35 | 2020-04-23 15:39 |
Reporter | fefe | Assigned To | Christian Grothoff | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | no change required | ||
Product Version | 0.7.0 | ||||
Target Version | 0.7.1 | Fixed in Version | 0.7.1 | ||
Summary | 0006197: TALER_MHD_handle_logs is not thread-safe | ||||
Description | The code for TALER_MHD_handle_logs is in exchange/src/mhd/mhd_config.c. It does this: 173 static int cache; 177 if (-1 == cache) 178 return; 179 if (0 == cache) 180 { 181 if (0 == 182 GNUNET_get_log_call_status (GNUNET_ERROR_TYPE_INFO, 183 "libmicrohttpd", 184 __FILE__, 185 __FUNCTION__, 186 __LINE__)) 187 { 188 cache = -1; 189 return; 190 } 191 } 192 cache = 1; This is not thread-safe. Since the function is called from a different software module, it should make no assumptions about being only called from a single thread. Use pthread_once or mutexes or atomic instructions. | ||||
Tags | No tags attached. | ||||
|
GNUNET_get_log_call_status can be shown to always return the same result given the same inputs. Hence, a race on 'once' does not matter, as both will compute the same result. Adding locking around such a fast computation that is pretty harmless if executed twice _or_ executing it once per thread (and requiring extra RAM) seem to be all worse, or even pointless. Note that MHD even includes an _intentional_ race. IMO, not all races are bad, if one can show (like in this case), that all execution orders result in sane, safe behavior. |
|
OK. I just wanted you to be aware of this pattern. :) |
|
Oh, I am. It exists in *every* GNUNET_log(), GNUNET_assert(), GNUNET_break() in the code... |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-04-22 12:35 | fefe | New Issue | |
2020-04-22 12:35 | fefe | Status | new => assigned |
2020-04-22 12:35 | fefe | Assigned To | => Christian Grothoff |
2020-04-22 15:14 | Christian Grothoff | Note Added: 0015732 | |
2020-04-22 15:14 | Christian Grothoff | Status | assigned => feedback |
2020-04-22 15:46 | Christian Grothoff | Assigned To | Christian Grothoff => |
2020-04-23 15:36 | fefe | Note Added: 0015765 | |
2020-04-23 15:36 | fefe | Status | feedback => new |
2020-04-23 15:38 | Christian Grothoff | Note Added: 0015768 | |
2020-04-23 15:39 | Christian Grothoff | Assigned To | => Christian Grothoff |
2020-04-23 15:39 | Christian Grothoff | Status | new => closed |
2020-04-23 15:39 | Christian Grothoff | Resolution | open => no change required |
2020-04-23 15:39 | Christian Grothoff | Fixed in Version | => 0.7.1 |
2020-04-23 15:39 | Christian Grothoff | Target Version | => 0.7.1 |