Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semget fails when there a semaphore with semid 0 #72

Closed
martinkoehler opened this issue Mar 20, 2016 · 2 comments
Closed

semget fails when there a semaphore with semid 0 #72

martinkoehler opened this issue Mar 20, 2016 · 2 comments

Comments

@martinkoehler
Copy link

I ran in the same bug as Siarhei Kuchynski:
The following code in line 64 of Log::Log4perl::Util::Semaphore should fix this:
64 defined($self->{id} = semget( $self->{ikey}, 1, 0 ))

He observes:
"When a semaphore with specified key (0x6f6e616e) and semid = 0 already
exists, semget fails for this semaphore:

bash-4.0# ipcs -s

Verberge zitierten Text
------ Semaphore Arrays --------

key semid owner perms nsems

0x6f6e616e 0 root 777 1

with the following error message

semget(1869504878) failed: at
/usr/share/perl5/vendor_perl//Log/Log4perl/Util/Semaphore.pm line 64.

This is caused by line 64 of Log::Log4perl::Util::Semaphore.pm

63 print "Semaphore '$self->{key}' already exists\n" if INTERNAL_DEBUG;

64 $self->{id} = semget( $self->{ikey}, 1, 0 )

65 or die "semget($self->{ikey}) failed: $!";

semget returns ID 0 for the key 1869504878 and dies, though 0 should be
considered to be valid ID
According to http://perldoc.perl.org/functions/semget.html:
semget KEY,NSEMS,FLAGS
Calls the System V IPC function semget(2). Returns the semaphore id, or the
undefined value on error.
It seems that init method should call die only if semget returns undefined
value, not zero.
"

@mschilli
Copy link
Owner

Thanks so much for pinpointing this, Martin, should be fixed now!
5e4b1b3

@martinkoehler
Copy link
Author

Dear Mike,
Thanks. I can confirm that this is fixed now

jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Nov 16, 2016
1.48 (2016/11/14)
   *    (ms) [rt.cpan.org #117377] Moved PatternLayout's documentation of
             DateFormat features to DateFormat.pm to avoid duplication
             and keep the two parts consistent, as suggested by Max Carey.
   *    (ms) [rt.cpan.org #114822] Split two lines with CVS-sensitive
             $Log.. variables into two parts.
   *    (ms) Semaphore issue fixed in Synchronized (reported by
             Siarhei Kuchynski and Martin Köhler):
          mschilli/log4perl#72
   *    (ms) header_text now works with syswrite (reported by Tom Metro):
          mschilli/log4perl#73
srivasta pushed a commit to srivasta/debian.packaging.liblog-log4perl-perl that referenced this issue May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants