1
Vote

DBServer segmentation fault when new configuration frame is received during data parsing

description

A segmentation fault sometimes occurs when a new configuration frame is received, and the configuration object is changed, while the function dataparser (line 897 in parser.c) is still running.

The segmentation fault most often happened to me at line 1227 of parser.c in the dataparser function. In gdb the cause was determined to be temp_cfg->pmu[j]->cnext->phnames[i] pointing in an inaccessaable memory location, as would happen if the memory were freed.

There is a mutex for the configuration object, but dataparser only locks it long enough to copy the structure (line 920-line 937). The copying is incomplete, however, since it's copying some pointers by reference. So when the original gets freed, the pointers are broken.

I solved this particular error by simply moving the pthread_mutex_unlock(&mutex_cfg) from line 1126 to line 1404, though a better solution may be a more complete copying routine.

Attached is DBServer's parser.c, with the changes outlined above.

file attachments

comments