Hello Andrew,

if gettimeofday fails it returns -1,
if gmtime fails it returns NULL.

To avoid segmentation faults, please, provide error handling as follows:

/* POSIX version ******************************************************/

#if defined(HAVE_SYS_TIME_H) && defined(HAVE_GETTIMEOFDAY)

#include <sys/time.h>
#include <time.h>
#include <errno.h>
#include <string.h>

double glp_time(void)
{     struct timeval tv;
      struct tm *tm;
      int j;
      double t;
      if (-1 == gettimeofday(&tv, NULL)) {
         xerror("%s\n", strerror(errno));
      }
      tm = gmtime(&tv.tv_sec);
      xassert(tm != NULL);
      j = jday(tm->tm_mday, tm->tm_mon + 1, 1900 + tm->tm_year);
      xassert(j >= 0);
      t = ((((double)(j - EPOCH) * 24.0 + (double)tm->tm_hour) * 60.0 +
         (double)tm->tm_min) * 60.0 + (double)tm->tm_sec) * 1000.0 +
         (double)(tv.tv_usec / 1000);
      return t;
}

In 2010 there was an error in gettimeofday as reported here:
http://sourceforge.net/mailarchive/forum.php?thread_name=p2j647fe9b11004200426j44e74180y3e627a0f302bed76%40mail.gmail.com&forum_name=mingw-w64-public

Best regards

Heinrich Schuchardt



Thank you for your bug report.

The exception happens in a Posix version of glp_time function. It is
difficult to say what is wrong, most likely it is some MINGW64
inconsistency, because under GNU/Linux this code works.

To fix the bug you may simply to disable using the configuration header
(created by the configure script) by replacing the fragment in file
glpk-4.51/src/env/time.c, lines 24-26:

#ifdef HAVE_CONFIG_H
#include<config.h>
#endif

with the following one:

#if 0
#include<config.h>
#endif

In this case an ANSI portable version will be used, which should work on
any platform.

Hope this helps.

BTW, who displays the message "warning: Invalid parameter passed to C
runtime function." ? It is not a glpk message.




_______________________________________________
Bug-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-glpk



_______________________________________________
Bug-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-glpk

Reply via email to