bug-m4
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

large diversions broken on mingw


From: Eric Blake
Subject: large diversions broken on mingw
Date: Sat, 09 Mar 2013 08:12:30 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3

Just a heads up that I'm trying to fix a bug in diversion handling,
exposed by 'make check', but which only shows on mingw or other
platforms where rename() can't change the name of an open file.  Most
Unix systems are unaffected, and I doubt many people test on mingw,
which is probably why no one has reported it even though I think the bug
has been present for months.

I'm still trying to ascertain whether released m4 has the bug, or
whether it is a regression introduced by a recent gnulib update.  But
the gdb session shows what is happening - if a diversion is large enough
to spill to a file, the act of closing it prior to the rename happens to
trigger a path that accidentally unlink()s the file.  I hope to have the
patch posted by Monday.

Starting program: /home/eblake/m4-branch/buildm64/src/m4 -I ../examples/
../checks/146.diversions
[New Thread 1476.0x348]

Breakpoint 1, m4_tmprename (oldnum=9001, newnum=9002) at
../../src/output.c:340
340       char *oldname = xstrdup (m4_tmpname (oldnum));
(gdb) n
341       const char *newname = m4_tmpname (newnum);
(gdb)
342       register_temp_file (output_temp_dir, newname);
(gdb) p oldname
$7 = 0xa4bbc8 "K:\\cygwin-2\\tmp/m4-zHYjYe/m4-9001"
(gdb) p newname
$8 = 0x39650 "K:\\cygwin-2\\tmp/m4-zHYjYe/m4-9002"
(gdb) shell ls /tmp/m4-zHYjYe
m4-9001
(gdb) n
343       if (oldnum == tmp_file1_owner)
(gdb)
356       else if (oldnum == tmp_file2_owner)
(gdb)
363               if (close_stream_temp (tmp_file2))
(gdb) s
close_stream_temp (fp=0x77c5fd00) at ../../lib/clean-temp.c:776
776       int fd = fileno (fp);
(gdb) n
779       int result = close_stream (fp);
(gdb)
780       int saved_errno = errno;
(gdb)
785       unregister_fd (fd);
(gdb)
787       errno = saved_errno;
(gdb)
788       return result;
(gdb) shell ls /tmp/m4-zHYjYe
(gdb)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]