|
From: Daniel J S. <dan...@ie...> - 2005-07-08 18:06:15
|
Ethan Merritt wrote: > On Friday 08 July 2005 01:57 am, Dave Denholm wrote: >>Need to be a little careful with registration of non-trivial objects, >>to make sure things are atomic wrt SIGINT. > > > That is indeed an issue in principle (but hard to debug I think!). > > New allocations (udv, whole plots, ...) are added at the end of a > linked list. But this allocate+link operation is not guaranteed > atomic by the current code. I'm not particularly worried by the > possibily of leaking a single newly-allocated block. But if the > SIGINT were to occur at just the wrong time, the final list link > pointer itself could become corrupt. That would show up as a > segfault rather than a memory leak. > > new_element = &(current_end_of_list->next); > new_element = gp_alloc(...); > <<<< SIGINT here is bad news > new_element->next = NULL; > > This is fixable, either by careful audit of all the routines that > do list insertion or by modifying gp_alloc to zero out new space > before returning it. I think the only true way to fix that sort of thing is if SIGINT is disabled before starting the memory allocation and re-enabled after recording the pointer in the linked list. Otherwise, the same problem can still occur inside gp_alloc() I would think. Dan |