Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-05-15 02:42:56 +0400
committerChristopher Faylor <me@cgf.cx>2012-05-15 02:42:56 +0400
commit3de7be4c1debaa8fcd27f8fc15509179fdb37b9f (patch)
tree4172968a5e085465b58b538e6401f6ecdb92b2a6 /winsup
parent77009cee1e0410a146ed4f7090e01c8a56cba670 (diff)
* DevNotes: Add entry cgf-000007.
* child_info.h (child_info_spawn::parent_winpid): Declare new field. (child_info_spawn::get_parent_handle): Declare new function. * dcrt0.cc (child_info_spawn::get_parent_handle): Define new function. (child_info_spawn::handle_spawn): Recreate parent handle if possible when dynamically loaded. Don't mess with parent handle if it's NULL. * spawn.cc (child_info_spawn::worker): Set parent_winpid appropriately.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog10
-rw-r--r--winsup/cygwin/DevNotes23
-rw-r--r--winsup/cygwin/child_info.h2
-rw-r--r--winsup/cygwin/dcrt0.cc17
-rw-r--r--winsup/cygwin/release/1.7.162
-rw-r--r--winsup/cygwin/spawn.cc1
6 files changed, 52 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index f40e4239c..cc96c3394 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,13 @@
+2012-05-14 Christopher Faylor <me.cygwin2012@cgf.cx>
+
+ * DevNotes: Add entry cgf-000007.
+ * child_info.h (child_info_spawn::parent_winpid): Declare new field.
+ (child_info_spawn::get_parent_handle): Declare new function.
+ * dcrt0.cc (child_info_spawn::get_parent_handle): Define new function.
+ (child_info_spawn::handle_spawn): Recreate parent handle if possible
+ when dynamically loaded. Don't mess with parent handle if it's NULL.
+ * spawn.cc (child_info_spawn::worker): Set parent_winpid appropriately.
+
2012-05-12 Christopher Faylor <me.cygwin2012@cgf.cx>
* DevNotes: Add entry cgf-000006.
diff --git a/winsup/cygwin/DevNotes b/winsup/cygwin/DevNotes
index aba32f1a2..e1d2b3f61 100644
--- a/winsup/cygwin/DevNotes
+++ b/winsup/cygwin/DevNotes
@@ -1,3 +1,26 @@
+2012-05-14 cgf-000007
+
+<1.7.16>
+- Fix invocation of strace from a cygwin process. Fixes:
+ http://cygwin.com/ml/cygwin/2012-05/msg00292.html
+</1.7.16>
+
+The change in cgf-000004 introduced a problem for processes which load
+cygwin1.dll dynamically. strace.exe is the most prominent example of
+this.
+
+Since the parent handle is now closed for "non-Cygwin" processes, when
+strace.exe tried to dynamically load cygwin1.dll, the handle was invalid
+and child_info_spawn::handle_spawn couldn't use retrieve information
+from the parent. This eventually led to a strace_printf error due to an
+attempt to dereference an unavailable cygheap. Probably have to fix
+this someday. You shouldn't use the cygheap while attempting to print
+an error about the inavailability of said cygheap.
+
+This was fixed by saving the parent pid in child_info_spawn and calling
+OpenProcess for the parent pid and using that handle iff a process is
+dynamically loaded.
+
2012-05-12 cgf-000006
<1.7.16>
diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h
index 36a22539c..ea23fc21e 100644
--- a/winsup/cygwin/child_info.h
+++ b/winsup/cygwin/child_info.h
@@ -66,6 +66,7 @@ public:
HANDLE subproc_ready; // used for synchronization with parent
HANDLE user_h;
HANDLE parent;
+ DWORD parent_winpid;
DWORD cygheap_reserve_sz;
unsigned fhandler_union_cb;
DWORD exit_code; // process exit code
@@ -175,6 +176,7 @@ public:
lock->release ();
return !!hExeced;
}
+ bool get_parent_handle ();
bool has_execed_cygwin () const { return iscygwin () && has_execed (); }
operator HANDLE& () {return hExeced;}
int worker (const char *, const char *const *, const char *const [], int,
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index aea2a564b..e28aecde9 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -625,13 +625,24 @@ child_info_fork::handle_fork ()
api_fatal ("recreate_mmaps_after_fork_failed");
}
+bool
+child_info_spawn::get_parent_handle ()
+{
+ parent = OpenProcess (PROCESS_VM_READ, false, parent_winpid);
+ moreinfo->myself_pinfo = NULL;
+ return !!parent;
+}
+
void
child_info_spawn::handle_spawn ()
{
extern void fixup_lockf_after_exec ();
HANDLE h;
- cygheap_fixup_in_child (true);
- memory_init (false);
+ if (!dynamically_loaded || get_parent_handle ())
+ {
+ cygheap_fixup_in_child (true);
+ memory_init (false);
+ }
if (!moreinfo->myself_pinfo ||
!DuplicateHandle (GetCurrentProcess (), moreinfo->myself_pinfo,
GetCurrentProcess (), &h, 0,
@@ -669,7 +680,7 @@ child_info_spawn::handle_spawn ()
Otherwise, we no longer need this handle so close it.
Need to do this after debug_fixup_after_fork_exec or DEBUGGING handling of
handles might get confused. */
- if (type != _CH_EXEC)
+ if (type != _CH_EXEC && child_proc_info->parent)
{
CloseHandle (child_proc_info->parent);
child_proc_info->parent = NULL;
diff --git a/winsup/cygwin/release/1.7.16 b/winsup/cygwin/release/1.7.16
index c73519da3..5656671f7 100644
--- a/winsup/cygwin/release/1.7.16
+++ b/winsup/cygwin/release/1.7.16
@@ -12,3 +12,5 @@ fifo. Fixes: http://cygwin.com/ml/cygwin/2012-05/msg00253.html
- Fix hang when calling pthread_testcancel in a canceled thread.
Fixes some of: http://cygwin.com/ml/cygwin/2012-05/msg00186.html
+- Fix invocation of strace from a cygwin process. Fixes:
+ http://cygwin.com/ml/cygwin/2012-05/msg00292.html
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 7e165cf8b..b9ec36f67 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -614,6 +614,7 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
SetHandleInformation (wr_proc_pipe, HANDLE_FLAG_INHERIT, 0);
SetHandleInformation (parent, HANDLE_FLAG_INHERIT, 0);
}
+ parent_winpid = GetCurrentProcessId ();
/* When ruid != euid we create the new process under the current original
account and impersonate in child, this way maintaining the different