Mail Archives: cygwin/2009/02/24/10:54:58
--------------010701080401010502090600
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hey all,
I noticed this weird cygwinism and wrote a little test case. It seems
stat() is returning EFAULT on some of my files. I've done some digging
through Cygwin source but couldn't see the source of the problem.
The testcase is a simple test.c which is compiled to test.exe. After
that, it does a stat("test") and a stat("test.exe"). It doesn't matter
if it runs stat on itself or on a different binary, so I chose to keep
things simple.
Here's the test case and output:
#include <errno.h>
int main() {
if(stat("test") != 0) perror("Calling stat() on test");
if(stat("test.exe") != 0) perror("Calling stat() on test.exe");
return 0;
}
// Calling stat() on test: Bad address
// Calling stat() on test.exe: Bad address
As far as I could see, the strace wasn't very informative. I've attached
the relevant parts.
This is Cygwin from the current bleeding-edge CVS. Could anybody explain
why stat() is returning -1 with errno set to EFAULT?
Sjors
--------------010701080401010502090600
Content-Type: text/plain;
name="statefault_strace.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="statefault_strace.txt"
// stat("test")
27 36374 [main] test 2236 dll_crt0_1: user_data->main 0x401050
23 36397 [main] test 2236 __set_errno: void dll_crt0_1(void*):908 val 0
62 36459 [main] test 2236 stat64: entering
26 36485 [main] test 2236 normalize_posix_path: src test
24 36509 [main] test 2236 cwdstuff::get: posix /home/Sjors/tests/statefault
22 36531 [main] test 2236 cwdstuff::get: (/home/Sjors/tests/statefault) = cwdstuff::get (0xC90008, 32768, 1, 0), errno 0
24 36555 [main] test 2236 normalize_posix_path: /home/Sjors/tests/statefault/test = normalize_posix_path (test)
22 36577 [main] test 2236 mount_info::conv_to_win32_path: conv_to_win32_path (/home/Sjors/tests/statefault/test)
24 36601 [main] test 2236 set_flags: flags: binary (0x2)
22 36623 [main] test 2236 mount_info::conv_to_win32_path: src_path /home/Sjors/tests/statefault/test, dst E:\overig\cygwin\root\home\Sjors\tests\statefault\test, flags 0xA, rc 0
43 36666 [main] test 2236 symlink_info::check: 0xC0000034 = NtQueryInformationFile (\??\E:\overig\cygwin\root\home\Sjors\tests\statefault\test)
46 36712 [main] test 2236 symlink_info::check: not a symlink
33 36745 [main] test 2236 symlink_info::check: 0 = symlink.check (E:\overig\cygwin\root\home\Sjors\tests\statefault\test.exe, 0x223BA0) (0xA)
25 36770 [main] test 2236 path_conv::check: this->path(E:\overig\cygwin\root\home\Sjors\tests\statefault\test.exe), has_acls(1)
41 36811 [main] test 2236 build_fh_pc: fh 0x6123C564
26 36837 [main] test 2236 stat_worker: (\??\E:\overig\cygwin\root\home\Sjors\tests\statefault\test.exe, 0x57, 0x6123C564), file_attributes 544
--- Process 2236, exception C0000005 at 611046AC
80 36917 [main] test 2236 _cygtls::handle_exceptions: In cygwin_except_handler exc 0xC0000005 at 0x611046AC sp 0x224AD4
25 36942 [main] test 2236 _cygtls::handle_exceptions: In cygwin_except_handler sig 11 at 0x611046AC
28 36970 [main] test 2236 _cygtls::handle_exceptions: In cygwin_except_handler calling 0x0
23 36993 [main] test 2236 __set_errno: void _cygtls::return_from_fault():259 val 14
23 37016 [main] test 2236 stat_worker: -1 = (\??\E:\overig\cygwin\root\home\Sjors\tests\statefault\test.exe, 0x57)
// perror("Calling stat() on test")
75 37091 [main] test 2236 fhandler_base::write: binary write
calling stat() on test 101 37192 [main] test 2236 fhandler_base::write: binary write
: 95 37287 [main] test 2236 fhandler_base::write: binary write
Bad address 134 37421 [main] test 2236 fhandler_base::write: binary write
// stat("test.exe")
94 37515 [main] test 2236 stat64: entering
23 37538 [main] test 2236 normalize_posix_path: src test.exe
22 37560 [main] test 2236 cwdstuff::get: posix /home/Sjors/tests/statefault
22 37582 [main] test 2236 cwdstuff::get: (/home/Sjors/tests/statefault) = cwdstuff::get (0xC90008, 32768, 1, 0), errno 14
24 37606 [main] test 2236 normalize_posix_path: /home/Sjors/tests/statefault/test.exe = normalize_posix_path (test.exe)
23 37629 [main] test 2236 mount_info::conv_to_win32_path: conv_to_win32_path (/home/Sjors/tests/statefault/test.exe)
22 37651 [main] test 2236 set_flags: flags: binary (0x2)
23 37674 [main] test 2236 mount_info::conv_to_win32_path: src_path /home/Sjors/tests/statefault/test.exe, dst E:\overig\cygwin\root\home\Sjors\tests\statefault\test.exe, flags 0xA, rc 0
45 37719 [main] test 2236 symlink_info::check: not a symlink
32 37751 [main] test 2236 symlink_info::check: 0 = symlink.check (E:\overig\cygwin\root\home\Sjors\tests\statefault\test.exe, 0x223BA0) (0xA)
25 37776 [main] test 2236 path_conv::check: this->path(E:\overig\cygwin\root\home\Sjors\tests\statefault\test.exe), has_acls(1)
40 37816 [main] test 2236 build_fh_pc: fh 0x6124C674
24 37840 [main] test 2236 stat_worker: (\??\E:\overig\cygwin\root\home\Sjors\tests\statefault\test.exe, 0x57, 0x6124C674), file_attributes 544
--- Process 2236, exception C0000005 at 611046AC
85 37925 [main] test 2236 _cygtls::handle_exceptions: In cygwin_except_handler exc 0xC0000005 at 0x611046AC sp 0x224AD4
25 37950 [main] test 2236 _cygtls::handle_exceptions: In cygwin_except_handler sig 11 at 0x611046AC
23 37973 [main] test 2236 _cygtls::handle_exceptions: In cygwin_except_handler calling 0x0
23 37996 [main] test 2236 __set_errno: void _cygtls::return_from_fault():259 val 14
23 38019 [main] test 2236 stat_worker: -1 = (\??\E:\overig\cygwin\root\home\Sjors\tests\statefault\test.exe, 0x57)
// perror("Calling stat() on test.exe");
58 38077 [main] test 2236 fhandler_base::write: binary write
calling stat() on test.exe 96 38173 [main] test 2236 fhandler_base::write: binary write
: 95 38268 [main] test 2236 fhandler_base::write: binary write
Bad address 126 38394 [main] test 2236 fhandler_base::write: binary write
--------------010701080401010502090600
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--------------010701080401010502090600--
- Raw text -