GNU Smalltalk 2.95e always copy gst.im

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

GNU Smalltalk 2.95e always copy gst.im

Thomas Girard
Hello,

I've just noticed that GNU Smalltalk 2.95e always try to copy the
Smalltalk image to the directory it was launched from.

For instance:
me@machine:~$ ls gst.im
ls: gst.im: No such file or directory
me@machine:~$ gst
GNU Smalltalk ready

st> ^D
me@machine:~$ ls gst.im
gst.im
me@machine:~$ cd /
me@machine:/$ gst
"Global garbage collection... done"
gst: Couldn't open file //gst.im
GNU Smalltalk ready

st>

Is this intended? GNU Smalltalk 2.3.6 does not exhibit this behavior.

Thanks,

Thomas




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: GNU Smalltalk 2.95e always copy gst.im

Thomas Girard
Le dimanche 21 octobre 2007 à 16:28 +0200, Thomas Girard a écrit :
> I've just noticed that GNU Smalltalk 2.95e always try to copy the
> Smalltalk image to the directory it was launched from.

Well, just after sending this email I've tried again using embedded
libsigsegv, statically linked against gst, and the image is not copied.

The gst exhibiting this strange behavior is dynamically linked against
Debian's libsigsegv.

Does that sound familiar?

Thanks,

Thomas




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: GNU Smalltalk 2.95e always copy gst.im

Paolo Bonzini
In reply to this post by Thomas Girard
I am not sure if it is the same bug, but the unexplainable behavior in
your message disappeared if I changed the timestamp comparisons to also
look at the nanosecond field.  It might be just a race condition that is
more frequent with the system libsigsegv (possibly because there is less
time between the installation of kernel files and the image?? I don't know).

You can try this patch, which I tested on ppc-apple-darwin and
i686-linux (Debian, both with/without system libsigsegv).

Paolo

2007-11-11  Paolo Bonzini  <[hidden email]>

        * libgst/files.c: Use _gst_file_is_newer.
        * libgst/sysdep.c: Remove _gst__gst_get_file_modify_time, add
        _gst_file_is_newer.
        * libgst/sysdep.h: Likewise.


--- orig/configure.ac
+++ mod/configure.ac
@@ -195,6 +195,9 @@ AC_CHECK_HEADERS_ONCE(stdint.h inttypes.
  sys/timeb.h termios.h sys/mman.h sys/file.h execinfo.h utime.h \
  sys/wait.h fcntl.h, [], [], [AC_INCLUDES_DEFAULT])
 
+AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec, struct stat.st_mtimensec,
+  struct stat.st_mtimespec.tv_nsec])
+
 AC_TYPE_INT8_T
 AC_TYPE_INT16_T
 AC_TYPE_INT32_T


--- orig/libgst/files.c
+++ mod/libgst/files.c
@@ -528,29 +528,27 @@ _gst_initialize (const char *kernel_dir,
 mst_Boolean
 ok_to_load_binary (void)
 {
-  time_t imageFileTime;
   const char *fileName;
 
-  imageFileTime = _gst_get_file_modify_time (_gst_binary_image_name);
-
-  if (imageFileTime == 0) /* not found */
+  if (!_gst_file_is_readable (_gst_binary_image_name))
     return (false);
 
   for (fileName = standard_files; *fileName; fileName += strlen (fileName) + 1)
     {
       char *fullFileName = _gst_find_file (fileName, GST_DIR_KERNEL);
-      mst_Boolean ok = (imageFileTime > _gst_get_file_modify_time (fullFileName));
+      mst_Boolean ok = _gst_file_is_newer (_gst_binary_image_name,
+   fullFileName);
       xfree (fullFileName);
       if (!ok)
         return (false);
     }
 
   if (site_pre_image_file
-      && imageFileTime <= _gst_get_file_modify_time (site_pre_image_file))
+      && !_gst_file_is_newer (_gst_binary_image_name, site_pre_image_file))
     return (false);
 
   if (user_pre_image_file
-      && imageFileTime <= _gst_get_file_modify_time (user_pre_image_file))
+      && !_gst_file_is_newer (_gst_binary_image_name, user_pre_image_file))
     return (false);
 
   return (true);
@@ -602,11 +600,7 @@ _gst_find_file (const char *fileName,
  dir == GST_DIR_BASE ? "" : LOCAL_KERNEL_DIR_NAME "/",
  fileName);
 
-      if (_gst_file_is_readable (localFileName)
-          /* If the system file is newer, use the system file instead.  */
-          && (!_gst_file_is_readable (fullFileName) ||
-      _gst_get_file_modify_time (localFileName) >=
-      _gst_get_file_modify_time (fullFileName)))
+      if (_gst_file_is_newer (localFileName, fullFileName))
  {
   xfree (fullFileName);
   return localFileName;


--- orig/libgst/sysdep.c
+++ mod/libgst/sysdep.c
@@ -943,16 +943,44 @@ error:
 
 
 
-time_t
-_gst_get_file_modify_time (const char *fileName)
+mst_Boolean
+_gst_file_is_newer (const char *file1, const char *file2)
 {
-  struct stat st;
+  static char *prev_file1;
+  static struct stat st1;
+  struct stat st2;
 
-  if (stat (fileName, &st) < 0)
-    return (0);
+  if (!prev_file1 || strcmp (file1, prev_file1))
+    {
+      if (prev_file1)
+ xfree (prev_file1);
+      prev_file1 = xstrdup (file1);
 
-  else
-    return (_gst_adjust_time_zone (st.st_mtime));
+      if (!_gst_file_is_readable (file1))
+        return false;
+      if (stat (file1, &st1) < 0)
+ return false;
+    }
+
+  if (!_gst_file_is_readable (file2))
+    return true;
+  if (stat (file2, &st2) < 0)
+    return true;
+
+  if (st1.st_mtime != st2.st_mtime)
+    return st1.st_mtime > st2.st_mtime;
+
+  /* 15 years have passed and nothing seems to have changed.  */
+#if defined HAVE_STRUCT_STAT_ST_MTIMENSEC
+  return st1.st_mtimensec >= st2.st_mtimensec;
+#elif defined HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
+  return st1.st_mtim.tv_nsec >= st2.st_mtim.tv_nsec;
+#elif defined HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
+  return st1.st_mtimespec.tv_nsec >= st2.st_mtimespec.tv_nsec;
+#else
+  /* Say that the image file is newer.  */
+  return true;
+#endif
 }
 
 


--- orig/libgst/sysdep.h
+++ mod/libgst/sysdep.h
@@ -130,12 +130,10 @@ extern unsigned _gst_get_milli_time (voi
 extern time_t _gst_get_time (void)
   ATTRIBUTE_HIDDEN;
 
-/* Returns the time the file FILENAME was last modified.  On UNIX
-   machines, this is the number of seconds since midnight Jan 1 1970
-   GMT.  On other platforms/environments, it's probably not important
-   exactly what it returns as long as it's unites consistent with
-   other accesses that client code may do to the file system.  */
-extern time_t _gst_get_file_modify_time (const char *fileName)
+/* Returns whether FILE1 is newer (or last modified at the same time as)
+   FILE2.  Returns true if FILE2 is not readable, false if FILE1 is not
+   readable.  */
+extern mst_Boolean _gst_file_is_newer (const char *file1, const char *file2)
   ATTRIBUTE_HIDDEN;
 
 /* Sets the time when FILENAME was last modified.  The times are in




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: GNU Smalltalk 2.95e always copy gst.im

Thomas Girard
Hello Paolo,

On Sun, Nov 11, 2007 at 11:28:20AM +0100, Paolo Bonzini wrote:
> I am not sure if it is the same bug, but the unexplainable behavior in
> your message disappeared if I changed the timestamp comparisons to also
> look at the nanosecond field.  It might be just a race condition that is
> more frequent with the system libsigsegv (possibly because there is less
> time between the installation of kernel files and the image?? I don't know).
>
> You can try this patch, which I tested on ppc-apple-darwin and
> i686-linux (Debian, both with/without system libsigsegv).

I've just tried your patch on GNU Smalltalk 2.95e and it works, thanks!

Regards,

Thomas


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk