[pypy-issue] [issue1465] cffi callback crashes in multithread environment

Amaury Forgeot d Arc tracker at bugs.pypy.org
Sun Apr 28 21:56:54 CEST 2013

Amaury Forgeot d Arc <amauryfa at gmail.com> added the comment:

A self-contained script below.
It does not crash when the thread was created from Python code
    thread.start_new_thread(lib.another_thread, (ffi.NULL,))

from cffi import FFI
ffi = FFI()
void register_thread_callback(int (*func)());
lib = ffi.verify("""
#include <stdio.h>
#include <pthread.h>

int (*global_thread_callback)();
void *another_thread(void *arg)
    printf("this is another thread\\n");
    return NULL;
void register_thread_callback(int (*func)())
    global_thread_callback = func;
    pthread_t tid;

    pthread_create(&tid, NULL, another_thread, NULL);

def thread_callback():
    print 'thread call back OK'
    return 0
while True:

nosy: +amaury

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list