| Jeroen Demeyer on Wed, 21 Nov 2018 16:07:09 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Should newblock() be protected by BLOCK_SIGINT? |
On 2018-11-21 15:47, Karim Belabas wrote:
1) the newly allocated block is unsafe as long as it's not completely
initialized but it's unreachable as long it's not added to the
linked list of blocks [either by bl_next(curblock) = x or cur_block =
x on exit].
Wouldn't it be a problem if bl_next(curblock) = x happens but not cur_block = x?
2) at the time it is linked / becomes reachable, it is complete (and safe
for inspection, deletion or whatever)
So what happens if we interrupt in the middle of newblock() is that we lose
the memory allocated by pari_malloc, which is not a big deal.
As far as I know, the compiler can execute the operations bl_size(x) = n; bl_refc(x) = 1; bl_next(x) = NULL; bl_prev(x) = cur_block; bl_num(x) = next_block++; if (cur_block) bl_next(cur_block) = x; return cur_block = x;in any order (as an optimization): it could change cur_block before it has finished preparing x. Or am I wrong?
Jeroen.