OSDN Git Service

* cygmagic: Add define name to warning.
authorcgf <cgf>
Wed, 26 Dec 2001 21:35:16 +0000 (21:35 +0000)
committercgf <cgf>
Wed, 26 Dec 2001 21:35:16 +0000 (21:35 +0000)
* dcrt0.cc (_dll_crt0): Check for changes in child_info size.
(multiple_cygwin_problem): Avoid "proc" errors when testing.  Just assume new
cygwin proc.
* shared_info.h (mount_info): Add 'cb' element for sanity checks.
(shared_info): Ditto.
* child_info.h (child_info): Add fhandler_union_size element for sanity
checking.
* shared.cc (open_shared): Detect shared region size mismatch between parent
and child.
(shared_info::initialize): Detect shared region size mismatch with expectation.
(memory_Init): Ditto.
* sigproc.cc (init_child_info): Correctly set cb in passed structure.
* shared.cc (open_shared):

winsup/cygwin/ChangeLog
winsup/cygwin/child_info.h
winsup/cygwin/cygmagic
winsup/cygwin/dcrt0.cc
winsup/cygwin/shared.cc
winsup/cygwin/shared_info.h
winsup/cygwin/sigproc.cc

index bafc5c7..dad164f 100644 (file)
@@ -1,5 +1,23 @@
 2001-12-26  Christopher Faylor  <cgf@redhat.com>
 
+       * cygmagic: Add define name to warning.
+       * dcrt0.cc (_dll_crt0): Check for changes in child_info size.
+       (multiple_cygwin_problem): Avoid "proc" errors when testing.  Just
+       assume new cygwin proc.
+       * shared_info.h (mount_info): Add 'cb' element for sanity checks.
+       (shared_info): Ditto.
+       * child_info.h (child_info): Add fhandler_union_size element for sanity
+       checking.
+       * shared.cc (open_shared): Detect shared region size mismatch between
+       parent and child.
+       (shared_info::initialize): Detect shared region size mismatch with
+       expectation.
+       (memory_Init): Ditto.
+       * sigproc.cc (init_child_info): Correctly set cb in passed structure.
+       * shared.cc (open_shared):
+
+2001-12-26  Christopher Faylor  <cgf@redhat.com>
+
        * include/getopt.h: Protect a declaratin.
 
 2001-12-26  Robert Collins  <rbtcollins@hotmail.com>
index 36dcd95..4b249a8 100644 (file)
@@ -28,7 +28,7 @@ enum
 
 #define EXEC_MAGIC_SIZE sizeof(child_info)
 
-#define CURR_CHILD_INFO_MAGIC 0xba17
+#define CURR_CHILD_INFO_MAGIC 0x8b3c
 
 /* NOTE: Do not make gratuitous changes to the names or organization of the
    below class.  The layout is checksummed to determine compatibility between
@@ -49,6 +49,7 @@ public:
   init_cygheap *cygheap;
   void *cygheap_max;
   HANDLE cygheap_h;
+  unsigned fhandler_union_cb;
 };
 
 class child_info_fork: public child_info
index 17c74b4..f63531d 100755 (executable)
@@ -14,7 +14,7 @@ while [ -n "$1" ]; do
     echo "#define $define $sum"
     curr=`sed -n "s/^#[        ]*define CURR_$define[  ][      ]*\([^  ][^     ]*\)/\1/p" $file`
     [ "$curr" == "$sum" ] || echo "*** WARNING WARNING WARNING WARNING WARNING ***
-*** $file: magic number changed old $curr != new $sum
+*** $file: magic number for $define changed old $curr != new $sum
 *** WARNING WARNING WARNING WARNING WARNING ***" 1>&2
 done >> $file_magic
 exit 0
index a6a446f..c68a2bc 100644 (file)
@@ -831,20 +831,29 @@ _dll_crt0 ()
       else if (fork_info->intro == PROC_MAGIC_GENERIC
               && fork_info->magic != CHILD_INFO_MAGIC)
        multiple_cygwin_problem ("proc", fork_info->magic, CHILD_INFO_MAGIC);
+      unsigned should_be_cb = 0;
       switch (fork_info->type)
        {
          case _PROC_FORK:
            user_data->forkee = fork_info->cygpid;
+           should_be_cb = sizeof (child_info_fork);
          case _PROC_SPAWN:
            if (fork_info->pppid_handle)
              CloseHandle (fork_info->pppid_handle);
          case _PROC_EXEC:
-           {
-             child_proc_info = fork_info;
-             cygwin_mount_h = child_proc_info->mount_h;
-             mypid = child_proc_info->cygpid;
-             break;
-           }
+           if (!should_be_cb)
+             should_be_cb = sizeof (child_info);
+           if (should_be_cb != fork_info->cb)
+             multiple_cygwin_problem ("proc size", fork_info->cb, should_be_cb);
+           else if (sizeof (fhandler_union) != fork_info->fhandler_union_cb)
+             multiple_cygwin_problem ("fhandler size", fork_info->fhandler_union_cb, sizeof (fhandler_union));
+           else
+             {
+               child_proc_info = fork_info;
+               cygwin_mount_h = child_proc_info->mount_h;
+               mypid = child_proc_info->cygpid;
+               break;
+             }
          default:
            system_printf ("unknown exec type %d", fork_info->type);
            fork_info = NULL;
@@ -1025,6 +1034,11 @@ __api_fatal (const char *fmt, ...)
 void
 multiple_cygwin_problem (const char *what, unsigned magic_version, unsigned version)
 {
+  if (_cygwin_testing && strstr (what, "proc"))
+    {
+      fork_info = NULL;
+      return;
+    }
   if (CYGWIN_VERSION_MAGIC_VERSION (magic_version) != version)
     api_fatal ("%s version mismatch detected - %p/%p.\n\
 You have multiple copies of cygwin1.dll on your system.\n\
index db99b07..f10fd7f 100644 (file)
@@ -103,10 +103,12 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, void *addr)
 void
 shared_info::initialize ()
 {
-  if (inited)
+  if (version)
     {
-      if (inited != SHARED_VERSION_MAGIC)
-       multiple_cygwin_problem ("shared", inited, SHARED_VERSION);
+      if (version != SHARED_VERSION_MAGIC)
+       multiple_cygwin_problem ("shared", version, SHARED_VERSION);
+      else if (cb != SHARED_INFO_CB)
+       multiple_cygwin_problem ("shared size", cb, SHARED_INFO_CB);
       return;
     }
 
@@ -115,7 +117,11 @@ shared_info::initialize ()
 
   /* Initialize tty table.  */
   tty.init ();
-  inited = SHARED_VERSION_MAGIC;
+  version = SHARED_VERSION_MAGIC;
+  cb = sizeof (*this);
+  if (cb != SHARED_INFO_CB)
+    system_printf ("size of shared memory region changed from %u to %u",
+                  SHARED_INFO_CB, cb);
 }
 
 void __stdcall
@@ -162,10 +168,16 @@ memory_init ()
     {
       mount_table->version = MOUNT_VERSION_MAGIC;
       debug_printf ("initializing mount table");
+      mount_table->cb = sizeof (*mount_table);
+      if (mount_table->cb != MOUNT_INFO_CB)
+       system_printf ("size of mount table region changed from %u to %u",
+                      MOUNT_INFO_CB, mount_table->cb);
       mount_table->init ();    /* Initialize the mount table.  */
     }
   else if (mount_table->version != MOUNT_VERSION_MAGIC)
     multiple_cygwin_problem ("mount", mount_table->version, MOUNT_VERSION);
+  else if (mount_table->cb !=  MOUNT_INFO_CB)
+    multiple_cygwin_problem ("mount table size", mount_table->cb, MOUNT_INFO_CB);
 
 }
 
index e8fa45c..16d71ee 100644 (file)
@@ -17,7 +17,6 @@ class mount_item
  public:
   /* FIXME: Nasty static allocation.  Need to have a heap in the shared
      area [with the user being able to configure at runtime the max size].  */
-
   /* Win32-style mounted partition source ("C:\foo\bar").
      native_path[0] == 0 for unused entries.  */
   char native_path[MAX_PATH];
@@ -42,7 +41,8 @@ class mount_item
 
 #define MOUNT_VERSION  27      // increment when mount table changes and
 #define MOUNT_VERSION_MAGIC CYGWIN_VERSION_MAGIC (MOUNT_MAGIC, MOUNT_VERSION)
-#define CURR_MOUNT_MAGIC 0xfe35
+#define CURR_MOUNT_MAGIC 0x41e0
+#define MOUNT_INFO_CB 16488
 
 class reg_key;
 
@@ -53,6 +53,7 @@ class mount_info
 {
  public:
   DWORD version;
+ unsigned cb;
   DWORD sys_mount_table_counter;
   int nmounts;
   mount_item mount[MAX_MOUNTS];
@@ -138,14 +139,17 @@ public:
                                  cygwin_version.api_minor)
 #define SHARED_VERSION_MAGIC CYGWIN_VERSION_MAGIC (SHARED_MAGIC, SHARED_VERSION)
 
-#define CURR_SHARED_MAGIC 0x6f6e
+#define SHARED_INFO_CB 47112
+
+#define CURR_SHARED_MAGIC 0x88e
 
 /* NOTE: Do not make gratuitous changes to the names or organization of the
    below class.  The layout is checksummed to determine compatibility between
    different cygwin versions. */
 class shared_info
 {
-  DWORD inited;
+  DWORD version;
+  DWORD cb;
  public:
   int heap_chunk_in_mb;
   DWORD sys_mount_table_counter;
index 6527313..2e40982 100644 (file)
@@ -857,13 +857,14 @@ void __stdcall
 init_child_info (DWORD chtype, child_info *ch, pid_t pid, HANDLE subproc_ready)
 {
   memset (ch, 0, sizeof *ch);
-  ch->cb = sizeof *ch;
+  ch->cb = chtype == PROC_FORK ? sizeof (child_info_fork) : sizeof (child_info);
   ch->intro = PROC_MAGIC_GENERIC;
   ch->magic = CHILD_INFO_MAGIC;
   ch->type = chtype;
   ch->cygpid = pid;
   ch->subproc_ready = subproc_ready;
   ch->pppid_handle = myself->ppid_handle;
+  ch->fhandler_union_cb = sizeof (fhandler_union);
 }
 
 /* Check the state of all of our children to see if any are stopped or