sem_get add warning about freeing variable
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
From manual page: https://php.net/function.sem-get
sem_get() has an important gotcha where if the variable is freed then the semaphore is released. I propose this is not quite a bug but could do with a red warning box e.g.
Warning: sem_get will also
auto_releasethe semaphore when the variable which holds it is freed (rather than the process ending). Ensure you store the result in a variable which is not overwritten, unset, or goes out of scope while the semaphore should be alive.
This behaviour can be demonstrated with the following:
$semGet = sem_get(1);
var_dump(sem_acquire($semGet, true));
// true: semaphore(1) acquired
var_dump(sem_acquire(sem_get(1), true));
// false: semaphore(1) already acquired
unset($semGet);
var_dump(sem_acquire(sem_get(1), true));
// true: semaphore(1) released by variable unset() so can be acquired again
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open the sem_get() manual page linked in the issue and inspect its existing warning or note sections. Add the warning about auto_release when the result variable is freed, overwritten, unset, or goes out of scope, then confirm the rendered page clearly documents the demonstrated behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100