Skip to content

[libco] race condition #3055

Closed
Closed
@hsmatulisgoogle

Description

Bug Report

There seems to be a race condition in libco:

if(!co_swap) {
co_init();
co_swap = (void (*)(cothread_t, cothread_t))co_swap_function;
}

Here co_swap is a static function pointer, which is assigned to a bunch of data in co_swap_function that corresponds to assembly instructions before first use.

However this code assume that pointer assignment is regular, which is likely platform dependent. Better to use pthread_once rather than checking if its null.

This code should probably be using inline assembly macros instead of writing data to an unsigned char and interpreting it as a function, then they wouldn't have to worry about initializing things before first use in the first place.

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions