Skip Menu |

This queue is for tickets about the Message-Passing-Output-Log-Any-Adapter CPAN distribution.

Report information
The Basics
Id: 120419
Status: resolved
Priority: 0/
Queue: Message-Passing-Output-Log-Any-Adapter

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.003
Fixed in: 0.004



Subject: Possible file locking issue in test suite
On FreeBSD systems the t/01_output.t test hangs: ... # Subtest: missing adapter_name ok 1 - instantiation dies 1..1 ok 1 - missing adapter_name # Subtest: without adapter_params ok 1 - 'instantiation ok' isa 'Message::Passing::Output::Log::Any::Adapter' ok 2 - consume ok ok 3 - message appeared in memory 1..3 ok 2 - without adapter_params # Subtest: with adapter_params ok 1 - 'instantiation ok' isa 'Message::Passing::Output::Log::Any::Adapter' (here it hangs) SIGINFO says: load: 0.81 cmd: perl 52502 [lockf] 242.16r 0.00u 0.09s 0% 16660k So it hangs while trying to get a lock. Running the test with truss shows these probably relevant lines: 52172: 0.360645278 0.000270426 openat(AT_FDCWD,"/tmp/rlMZTM7L47",O_RDWR|O_EXLOCK|O_NOFOLLOW|O_CREAT|O_EXCL,0600) = 3 (0x3) ... 52172: 0.369712352 0.000025702 openat(AT_FDCWD,"/tmp/rlMZTM7L47",O_WRONLY|O_APPEND|O_CREAT,0666) = 4 (0x4) ... 52172: 13.790323631 13.400977220 flock(0x4,0x2) = 131 (0x83) So the temporary file was already opened with a lock (O_EXLOCK) (this is standard behavior of File::Temp on *BSD systems) and the flock syscall later hangs. Probably this could be fixed by not locking the temporary file in the beginning, i.e. using something like this: ($fh, $filename) = tempfile($template, EXLOCK => 0); Note that http://matrix.cpantesters.org/?dist=Message-Passing-Output-Log-Any-Adapter+0.003 shows no results for netbsd and openbsd, so these operating systems are also affected. The fails on freebsd probably happen because a watcher script killed the hanging test.
Thanks for the report but this looks like an issue in File::Temp's tempfile function to me.
RT-Send-CC: dagolden [...] cpan.org
On 2017-02-27 16:07:58, ABRAXXA wrote: Show quoted text
> Thanks for the report but this looks like an issue in File::Temp's > tempfile function to me.
At least it's documented, and the documentation also discusses possible problems with multiple locks: If the operating system supports it (for example BSD derived systems), the filehandle will be opened with O_EXLOCK (open with exclusive file lock). This can sometimes cause problems if the intention is to pass the filename to another system that expects to take an exclusive lock itself (such as DBD::SQLite) whilst ensuring that the tempfile is not reused. In this situation the "EXLOCK" option can be passed to tempfile. By default EXLOCK will be true (this retains compatibility with earlier releases). However, I fail to understand why the locking is done at all. Is it for extra security reasons? I cannot see how advisory locking can help. On the other hand, O_EXLOCK was not implemented on Linux for a long time and probably never will be, so this will always be a source of confusion (I already wrote dozens of bug reports for this issue). Maybe it's really better if File::Temp nowhere uses EXLOCK by default.
Thanks for the explanation and suggested fix, I've released it as 0.004.