[ET Trac] #2832: possible race condition in LoopControl

Roland Haas trac-noreply at einsteintoolkit.org
Tue Nov 5 11:19:54 CST 2024


#2832: possible race condition in LoopControl

 Reporter: Roland Haas
   Status: new
Milestone: 
  Version: 
     Type: bug
 Priority: major
Component: 

Comment (by Roland Haas):

Right, I was thinking of it but did not consider it as likely to pass the smell test. Namely: how to nicely combine that one with `std::vector`? Works fine to replace the naked `new` of course. For the `std::vector` one would use something like this:

```
lc_fine_thread_comm_t lc_fine_thread_comm = nulltpr;

[...]

if (!lc_fine_thread_comm) {
  lc_fine_thread_comm = static_cast<lc_fine_thread_comm*>(posix_memalign(n*sizeof(*lc_fine_thread_comm), 128));
  for(size_t i = 0 ; i < n ; ++i) {
    lc_fine_thread_comm_t* ptr = new (lc_fine_thread_comm+i) lc_fine_thread_comm_t();
    assert(ptr == lc_fine_thread_comm+i); // apparently not guaranteed
  }
}
```

and similar awkwardness if we ever were to `free` the array.

--
Ticket URL: https://bitbucket.org/einsteintoolkit/tickets/issues/2832/possible-race-condition-in-loopcontrol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.einsteintoolkit.org/pipermail/trac/attachments/20241105/ce0e3fd8/attachment.htm>


More information about the Trac mailing list