Opened 7 years ago

Closed 6 years ago

#182 closed defect (fixed)

pthread: implement key destructor

Reported by: KO Myung-Hun Owned by:
Priority: major Milestone:
Component: *none Version:
Severity: medium Keywords:
Cc:

Description

Hi/2.

Currently, pthread does not call key destructor at thread exit. This causes some tests to fail. For example, googletest.

Here is the patch.

Review, please...

Attachments (1)

key_destructor.diff (2.7 KB ) - added by KO Myung-Hun 7 years ago.
Patch for key destructor implementation

Download all attachments as: .zip

Change History (2)

by KO Myung-Hun, 7 years ago

Attachment: key_destructor.diff added

Patch for key destructor implementation

comment:1 by dmik, 6 years ago

Resolution: fixed
Status: newclosed

Hey KoMH. Added your patch in r2346 with one slight modification: clearing the key's value before calling the destructor, as the standard requires (see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_key_create.html).

Other notes:

  1. The standard also requires to run several destructor loops but I don't fully understand which situations it is going to cover. In our implementation this makes no sense unless destructors create new keys (wich is clearly would be a misuse).
  1. Your implementation is not thread safe. Meaning that if two threads will attempt to create a new key at the same time, the key list corruption is most likely about to happen. I accepted your patch, however, because I think that this situation would also be a misuse. It is supposed that all needed keys are normally created on the main thread before any thread that uses them starts. This approacy avoids any potential races. If we find a program that requires thread safety (or a proof that it's a posix requirement), we will add it. But the current implementation it's already better than nothing so it's fine for now.
Note: See TracTickets for help on using tickets.