Re: [Help-glpk] things I don't understand in src/env/time.c + bugs + suggested patch

2017-01-29 Thread Chris Matrakidis
Hi Andrew, > As Heinrich noticed, gmtime, strerror, and strtok are non-thread-safe Checking the online MSDN documentation, I see that strtok is also safe on Windows for multiple threads, but It isn't clear what happens for strerror - it is implied that a pointer to a fixed string is returned but

Re: [Help-glpk] things I don't understand in src/env/time.c + bugs + suggested patch

2017-01-29 Thread Heinrich Schuchardt
On 01/29/2017 06:22 PM, Andrew Makhorin wrote: > Hi Chris, > >>> Not sure, but gmtime_s looks like a MSVC function. Could you point me >>> out where gmtime_s is standardized? Thanks. >> >> gmtime_s is included in the (optional) annex K of C11. However, the >> parameters are reversed compared to th

Re: [Help-glpk] things I don't understand in src/env/time.c + bugs + suggested patch

2017-01-29 Thread Andrew Makhorin
Hi Chris, > > Not sure, but gmtime_s looks like a MSVC function. Could you point me > > out where gmtime_s is standardized? Thanks. > > gmtime_s is included in the (optional) annex K of C11. However, the > parameters are reversed compared to the MSVC version and the standard > one returns struct

Re: [Help-glpk] Thred safety

2017-01-29 Thread Andrew Makhorin
Hi Heinrich, > > If a multithreaded application calls the same GLPK library function in > > two threads at the same time, unexpected results may occur. > > > > Gmtime, strerror and strtok use one global buffer each for all > > threads. > > > > They do not use thread local memory. > > > > Proba

Re: [Help-glpk] Thred safety

2017-01-29 Thread Andrew Makhorin
> If a multithreaded application calls the same GLPK library function in > two threads at the same time, unexpected results may occur. > > Gmtime, strerror and strtok use one global buffer each for all > threads. > > They do not use thread local memory. > Probably you are right. (At least glib

Re: [Help-glpk] Thred safety

2017-01-29 Thread Heinrich Schuchardt
If a multithreaded application calls the same GLPK library function in two threads at the same time, unexpected results may occur. Gmtime, strerror and strtok use one global buffer each for all threads. They do not use thread local memory. On 1/29/17, 09:35 Andrew Makhorin wrote: > Here

Re: [Help-glpk] Thred safety

2017-01-29 Thread Andrew Makhorin
> Here is a list of functions that are not thread safe under POSIX 2008: > http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_01 > > Problematic coding includes: > strtok used in mplsql.c > gmtime used in time.c > strerror used in stream.c, gzguts.h, mpl6.c, glprpr.