Question about flock - potential memory corruption?

Qian Hong fracting@gmail.com
Tue Sep 8 05:54:00 GMT 2015


Hi Sam,

Thank you very much for your reply!

On Tue, Sep 8, 2015 at 12:41 PM, Sam Edge <sam.edge@dwalin.fsnet.co.uk> wrote:
> Erm ... slight technical hitch? Your example flock.c doesn't call
> fork(), nor does it use your two macros MAX_ITER & CHILDREN.

Good question. This problem was originally found when running autom4te on Wine.

In autom4te-2.69, we have:
 68 my $flock_implemented = 'yes';
 982 $icache_file = new Autom4te::XFile $icache, O_RDWR|O_CREAT;
 983 $icache_file->lock (LOCK_EX)
 984   if ($flock_implemented eq "yes");

This cause problem on Wine on some machine, while it works fine on
some other machine.

After tracking down, I successfully reproduce the problem with Cygwin
using the attached test case stc-flock-fork-2.c, which is changed
based on another test case from an old cygwin mailing list archive
[1].

Later then, I found that even without fork(), we can still reproduce
the same problem, Valgrind + Wine shows same warning either with or
without fork, so I simply the test case a bit further, that's why you
didn't see fork in my test case.

Thank for your comment, it's good to make things clearer to everybody.

Any further comment is welcome!

[1] https://www.cygwin.com/ml/cygwin/2011-08/txt00012.txt

-- 
Regards,
Qian Hong

-
http://www.winehq.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stc-flock-fork-2.c
Type: text/x-csrc
Size: 2505 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20150908/4e1e6207/attachment.bin>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list