Skip to content

Improper locking bugs due to the unrelesed locks before destorying #232

@ycaibb

Description

@ycaibb

Hi, developers, thank you for your checking! Should the lock be released before destroying it(Line 158 and 164)? According to this, it says It shall be safe to destroy an initialized mutex that is unlocked.

neko/vm/threads.c

Lines 150 to 165 in 1df580c

pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
pthread_mutex_init(&p.lock,NULL);
pthread_mutex_lock(&p.lock);
// force the use of a the GC method to capture created threads
// this function should be defined in gc/gc.h
if( GC_pthread_create((pthread_t*)handle,&attr,&ThreadMain,&p) != 0 ) {
pthread_attr_destroy(&attr);
pthread_mutex_destroy(&p.lock);
return 0;
}
pthread_mutex_lock(&p.lock);
pthread_attr_destroy(&attr);
pthread_mutex_destroy(&p.lock);
return 1;

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