Bug#826322: liblog-log4perl-perl: semget fails when there a semaphore with semid 0

Martin Köhler Martin.Koehler at desy.de
Sat Jun 4 15:03:07 UTC 2016


Package: liblog-log4perl-perl
Version: 1.44-1
Severity: important

Dear Maintainer,
as reported via github directly to the maintainer
https://github.com/mschilli/log4perl/issues/72#event-604356082

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.
"
Fix is:
-       $self->{id} = semget( $self->{ikey}, 1, 0 )
+       defined( $self->{id} = semget( $self->{ikey}, 1, 0 ) )

Michael fixed this in commit
https://github.com/mschilli/log4perl/commit/5e4b1b3b6cd3146d2f0e88bf5de3225ab62fee6c

Could you please backport the fix.
Thanks
 Best Martin



-- System Information:
Debian Release: 8.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/1 CPU core)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages liblog-log4perl-perl depends on:
ii  perl  5.20.2-3+deb8u4

Versions of packages liblog-log4perl-perl recommends:
ii  libipc-shareable-perl  0.61-1
ii  liblog-dispatch-perl   2.44-1

Versions of packages liblog-log4perl-perl suggests:
pn  libdbd-csv-perl  <none>
pn  libxml-dom-perl  <none>

-- no debconf information



More information about the pkg-perl-maintainers mailing list