Skip to content

thread race condition accessing axl_kvtrees[id] #85

@rhaas80

Description

@rhaas80

In

kvtree* file_list = axl_kvtrees[id];

axl_kvtrees is accessed without protecting from race conditions.

Looking eg at

AXL/src/axl.c

Line 98 in a799cd9

pthread_mutex_lock(&id_lock);

where one has

   pthread_mutex_lock(&id_lock);

    int id = axl_kvtrees_count;
    axl_kvtrees_count++;

    axl_kvtrees = realloc(axl_kvtrees, sizeof(struct kvtree*) * axl_kvtrees_count);
    axl_kvtrees[id] = new;

    pthread_mutex_unlock(&id_lock);

it seems clear that axl_kvtress is accessed in a multi-threaded context. Since realloc can move the block of data when allocating memory ie in new_ptr = realloc(old_ptrs, new_size) there is no guarantee that new_ptr == old-ptr one must not assume that axl_kvtrees[id] is accessible without the lock.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions