Seg Fault in strftime

Michael Enright mike@kmcardiff.com
Fri Jul 31 19:50:00 GMT 2015


On Fri, Jul 31, 2015 at 5:51 AM, Jon TURNEY wrote:
> On 31/07/2015 01:16, Michael Enright wrote:
>>
> It would be very helpful if you could tweak the testcase there and produce
> one which reproduces your problem.
>
> [1]
> https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commitdiff;h=75d5f68aabf62c42884ff935f888b12bbcd00001
> [2] https://sourceware.org/ml/newlib/2015/msg00321.html
>
I have not found it simple to reproduce the symptoms in the
intepreter, but I have found that if I do
struct tm manually_initialized;
manually_initialized.tm_year = 2000;
strftime(buf, buf_size, "%Z", &manually_initialized);
The printed time zone is garbage, which is an indication of danger.
Unlike my complex case, the tzname twins are not corrupted by this
exercise.

If I do
struct tm zeroed = {0};
manually_initialized.tm_year = 2000;
strftime(buf, buf_size, "%Z", &zero_initialized);
The printed time zone is PST (TZ happens to be "America/Los_Angeles")

Aside: I am not super-certain of the zero-initialized semantics with
respect to the language. The idiom I used is defined in C++ but the
program is C.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list