This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

localtime_r segfaults, localtime doesn't... same values passed to each function...


This works...
 
struct tm *sci_localtime (time_t timep) {
    struct tm *result;
    if ((result = localtime(&timep)) == NULL) {
    int errsv = errno;
        fprintf (stderr, "\nError Code %i: %s at line
%i of %s function in %s \
            \n", strerror (errsv), 2,
"sci_localtime_r", "sci_time.c");
        exit (EXIT_FAILURE);
    } else {
        return (result);
    }
}
 
This doesn't...
 
struct tm *sci_localtime_r (time_t timep) {
    struct tm *result;
    if ((localtime_r(&timep, result)) == NULL) {
    int errsv = errno;
        fprintf (stderr, "\nError Code %i: %s at line
%i of %s function in %s \
            \n", strerror (errsv), 2,
"sci_localtime_r", "sci_time.c");
        exit (EXIT_FAILURE);
    } else {
        return (result);
    }
}
 
Keep in mind, I have a wrapper for time() and
asctime_r() and they work just fine. The segfault is
being caused by localtime_r(). I mean I changed it to
localtime() and everything worked. When I change it
back to localtime_r() it doesn't. Anyone ever
encounter this bug? Anyway, I plan to update my Cygwin
DLL to see if it fixes the problem.

--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]