3

thisによると、pthread_join は出力パラメーター **thread_return を pd->result に設定し、pd を解放します。これは大丈夫ですか、何か不足していますか、それとも glibc に重大なバグがありますか?

    /* We mark the thread as terminated and as joined.  */
    pd->tid = -1;

    /* Store the return value if the caller is interested.  */
    if (thread_return != NULL)
      *thread_return = pd->result;


    /* Free the TCB.  */
    __free_tcb (pd);
4

1 に答える 1

1

__free_tbcfreepdではなく、スレッドのスタック、つまりpd->tpp(こちらも参照)。したがってpd->result、これらのステートメントの後でも有効なポインターです。

于 2013-01-27T13:35:45.433 に答える