http://bugs.winehq.org/show_bug.cgi?id=16948
Summary: tmpfile() write, seek(0) and read does not return same data Product: Wine Version: unspecified Platform: All OS/Version: Linux Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: -unknown AssignedTo: wine-bugs@winehq.org ReportedBy: lkcl@lkcl.net
ok this is tested from python (import os) so it _could_ be done a little simpler - like... using c. didn't want to forget about it so am raising it here.
this is the mode opening a tmpfile:
fixme:msvcrt:MSVCRT__sopen : pmode 0x1464e0 ignored
http://bugs.python.org/issue4956 $ ./python.exe -i Python 2.5.2 (r252:60911, Jan 15 2009, 23:28:55) [gcc] on win32 Type "help", "copyright", "credits" or "license" for more information.
import os f = os.tmpfile() f.name
'<tmpfile>'
f.write("hello\n") f.flush() f
<open file '<tmpfile>', mode 'w+b' at 0x001B34E8>
f.tell()
6L
f.seek(0) f.tell()
0L
f.read()
''
it's as if it's impossible to read from the tmpfile. which kinda defeats the object of having one :)
c:\windows\temp exists but c:\windows\tmp does not.
http://bugs.winehq.org/show_bug.cgi?id=16948
Dan Kegel dank@kegel.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dank@kegel.com
--- Comment #1 from Dan Kegel dank@kegel.com 2009-01-15 21:22:38 --- You forgot to mention that, according to that bug report, you need msys to trigger the bug, too.
Can you provide a linux shell script to reproduce the problem from start to finish?
http://bugs.winehq.org/show_bug.cgi?id=16948
--- Comment #2 from Luke Kenneth Casson Leighton lkcl@lkcl.net 2009-01-16 10:10:13 --- hiya dan, actually it's much simpler - and much worse! :) when running wine z:/src/winebug/a.exe i get the attached segfault. when running the same program under msys, no segfault occurs, but the reported bug (seek works but read fails) can be duplicated. gcc -g -g test.c a.exe also attached (otherwise you have to install msys and mingw under wine).
http://bugs.winehq.org/show_bug.cgi?id=16948
--- Comment #3 from Luke Kenneth Casson Leighton lkcl@lkcl.net 2009-01-16 10:11:03 --- Created an attachment (id=18730) --> (http://bugs.winehq.org/attachment.cgi?id=18730) source code test case
http://bugs.winehq.org/show_bug.cgi?id=16948
--- Comment #4 from Luke Kenneth Casson Leighton lkcl@lkcl.net 2009-01-16 10:11:26 --- Created an attachment (id=18731) --> (http://bugs.winehq.org/attachment.cgi?id=18731) precompiled test case (gcc -g -g test.c)
http://bugs.winehq.org/show_bug.cgi?id=16948
--- Comment #5 from Luke Kenneth Casson Leighton lkcl@lkcl.net 2009-01-16 10:11:45 --- Created an attachment (id=18732) --> (http://bugs.winehq.org/attachment.cgi?id=18732) segfault of wine ./a.exe
http://bugs.winehq.org/show_bug.cgi?id=16948
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, testcase
http://bugs.winehq.org/show_bug.cgi?id=16948
Vincent Povirk madewokherd@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |madewokherd@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=16948
Juan Lang juan_lang@yahoo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #18732|application/octet-stream |text/plain mime type| |
http://bugs.winehq.org/show_bug.cgi?id=16948
Juan Lang juan_lang@yahoo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |juan_lang@yahoo.com Status|UNCONFIRMED |NEW Component|-unknown |msvcrt Ever Confirmed|0 |1 Summary|tmpfile() write, seek(0) and|tmpfile() fails when run |read does not return same |from Unix path |data |
--- Comment #6 from Juan Lang juan_lang@yahoo.com 2009-01-16 11:56:39 --- Confirming, though I compiled like so: winegcc -g test.c -lmsvcrt
Omitting -lmsvcrt didn't produce the crash, as it used gcc's libc instead.
Here's a snip from my backtrace (which has a little more info): =>0 0x601cf01e MSVCRT_fwrite+0x2e(ptr=0x6019f7d6, size=5, nmemb=1, file=(nil)) [/home/juan/src/wine/dlls/msvcrt/file.c:2403] in msvcrt (0x0032fe88) 1 0x6019f583 main+0x5f() [/home/juan/foo/tmp/test.c:9] in a.out (0x0032fed8) 2 0x6019f6d8 __wine_spec_exe_entry+0x88(peb=0x7ffdf000) [/home/juan/src/wine/dlls/winecrt0/exe_entry.c:36] in a.out (0x0032ff08) 3 0x7b8762a8 start_process+0x98(arg=(nil)) [/home/juan/src/wine/dlls/kernel32/process.c:904] in kernel32 (0x0032ffe8) 4 0x6413a697 wine_switch_to_stack+0x17() in libwine.so.1 (0x00000000) 0x601cf01e MSVCRT_fwrite+0x2e [/home/juan/src/wine/dlls/msvcrt/file.c:2403] in msvcrt: movl 0x4(%edi),%eax 2403 if(file->_cnt) {
The problem is tmpfile() is returning NULL. Here's a snip from a +relay log: 0009:Call msvcrt.tmpfile() ret=60321546 0009:Call KERNEL32.GetFileAttributesA(6038cc60 "\s8.") ret=6034bf27 0009:Ret KERNEL32.GetFileAttributesA() retval=ffffffff ret=6034bf27 fixme:msvcrt:MSVCRT__sopen : pmode 0x7bca91a1 ignored 0009:Call KERNEL32.CreateFileA(6038cc60 "\s8.",c0010000,00000007,0032fdb0,00000004,04000080,00000000) ret=6034e85a 0009:Ret KERNEL32.CreateFileA() retval=ffffffff ret=6034e85a
Note the path: "\s8.". tmpnam() returns a filename in the root directory of whatever the current drive is: p = s + sprintf(s, "\s%s.", tmpstr);
The trouble comes about when running the test program from a Unix path. Copying it to somewhere in the c: drive causes it to succeed.
I'm guessing tmpnam() needs to be adjusted to return a file in %TMP%, based on its description on MSDN, but without test cases to confirm it I'm not sure.
http://bugs.winehq.org/show_bug.cgi?id=16948
Juan Lang juan_lang@yahoo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |1.1.13
--- Comment #7 from Juan Lang juan_lang@yahoo.com 2009-01-16 11:57:47 --- Forgot to specify the Wine version.
http://bugs.winehq.org/show_bug.cgi?id=16948
--- Comment #8 from Juan Lang juan_lang@yahoo.com 2009-01-16 12:03:57 --- Created an attachment (id=18733) --> (http://bugs.winehq.org/attachment.cgi?id=18733) Patch
This patch fixes it, though a little testing wouldn't hurt.
http://bugs.winehq.org/show_bug.cgi?id=16948
Juan Lang juan_lang@yahoo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch
http://bugs.winehq.org/show_bug.cgi?id=16948
Juan Lang juan_lang@yahoo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Keywords|patch | Resolution| |INVALID
--- Comment #9 from Juan Lang juan_lang@yahoo.com 2009-01-16 12:18:33 --- Hmm, according to tmpfile()'s description on MSDN, "The temporary file is created in the root directory." Thus the patch is incorrect, and the problem is that z:\ is not writable by you.
Workaround: run from a drive whose root is writable, e.g. c:
http://bugs.winehq.org/show_bug.cgi?id=16948
Juan Lang juan_lang@yahoo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #18733|0 |1 is obsolete| |
http://bugs.winehq.org/show_bug.cgi?id=16948
--- Comment #10 from Juan Lang juan_lang@yahoo.com 2009-01-16 12:25:57 --- For further reference, glibc works around this "feature" of msvcrt. See the following discussion of it, and their workaround: http://www.mail-archive.com/bug-gnulib@gnu.org/msg05721.html
http://bugs.winehq.org/show_bug.cgi?id=16948
Dan Kegel dank@kegel.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID |
--- Comment #11 from Dan Kegel dank@kegel.com 2009-01-16 12:53:49 --- gnulib != glibc, but the link's interesting anyway.
I think we should make this work for the common case where z:/ is not writable somehow, so reopening.
http://bugs.winehq.org/show_bug.cgi?id=16948
Dmitry Timoshkov dmitry@codeweavers.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Platform|All |Other
http://bugs.winehq.org/show_bug.cgi?id=16948
--- Comment #12 from Austin English austinenglish@gmail.com 2010-08-05 08:38:56 --- With the precompiled exe, in wine-1.3.0-167-g65d1c99
putting it in ~/.wine/drive_c gives
austin@laptop:~/.wine/drive_c$ wine a.exe fixme:msvcrt:MSVCRT__sopen : pmode 0x60fdc8 ignored filepos: 5 filepos: 0 buffer: �/h�@filepos: 0
and in $HOME, I get a crash:
Backtrace: =>0 0x6858b4a7 MSVCRT_fwrite+0x27(ptr=0x403000, size=0x0005, nmemb=0x0001, file=(nil)) [/home/austin/wine-git/dlls/msvcrt/file.c:2564] in msvcrt (0x0060fe48) 1 0x00401345 main+0x54(argc=0x0001, argv=0x1103a0) [C:/src/winebug-16948/test.c:7] in a (0x0060fe80) 2 0x00401298 in a (+0x1297) (0x0060fe90)
native msvcrt crashes from $HOME as well, though...however, the drive_c results are different:
austin@laptop:~/.wine/drive_c$ wine a.exe filepos: 5 filepos: 0 buffer: hello(filepos: 5
(notice the unreadable characters instead of 'hello').
http://bugs.winehq.org/show_bug.cgi?id=16948
Bruno Jesus 00cpxxx@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |00cpxxx@gmail.com
--- Comment #13 from Bruno Jesus 00cpxxx@gmail.com 2011-09-20 21:54:17 CDT --- Still present in 1.3.28.
http://bugs.winehq.org/show_bug.cgi?id=16948
Piotr Caban piotr.caban@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |piotr.caban@gmail.com
--- Comment #14 from Piotr Caban piotr.caban@gmail.com 2012-10-16 10:39:48 CDT --- tmpfile fails when root directory is read-only on windows unless VirtualStore is enabled.
What was tested: - tmpfile on read-only file system - tmpfile fails - tmpfile on c: drive (user without privileges to write directly to c:\ directory), the file was created in VirtualStore, function has succeeded
I've sent a patch that fixes attached test when tmpfile succeeds (http://source.winehq.org/patches/data/91032).
https://bugs.winehq.org/show_bug.cgi?id=16948
Sebastian Lackner sebastian@fds-team.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |sebastian@fds-team.de
https://bugs.winehq.org/show_bug.cgi?id=16948
Ken Sharp imwellcushtymelike@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch Status|REOPENED |NEW Severity|enhancement |normal
--- Comment #15 from Ken Sharp imwellcushtymelike@gmail.com --- Was the patch ever accepted?
https://bugs.winehq.org/show_bug.cgi?id=16948
--- Comment #16 from Piotr Caban piotr.caban@gmail.com --- (In reply to Ken Sharp from comment #15)
Was the patch ever accepted?
Yes, the patch I've mentioned was committed.
It's not clear for me if there's a bug. Currently wine behaves the same as Windows XP. On the other hand it would be nice to have support for VirtualStore so the function may work if root path is read-only.
https://bugs.winehq.org/show_bug.cgi?id=16948
Piotr Caban piotr.caban@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Fixed by SHA1| |e4c9a2ec81b8029876d588e0958 | |7db40ab65ee69 Status|NEW |RESOLVED
--- Comment #17 from Piotr Caban piotr.caban@gmail.com --- Starting from msvcr110 native creates the file in temp directory. I have changed wine's implementation to do the same for all msvcr* versions. Marking the bug as fixed.
https://bugs.winehq.org/show_bug.cgi?id=16948
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #18 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 2.10.
https://bugs.winehq.org/show_bug.cgi?id=16948
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |2.0.x
https://bugs.winehq.org/show_bug.cgi?id=16948
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|2.0.x |---
--- Comment #19 from Michael Stefaniuc mstefani@winehq.org --- Removing the 2.0.x milestone from bugs included in 2.0.3.