Threads
Corinna Vinschen
corinna-cygwin@cygwin.com
Fri Oct 24 12:54:00 GMT 2014
On Oct 24 12:05, Jon TURNEY wrote:
> On 23/10/2014 16:37, Corinna Vinschen wrote:
> >On Oct 23 08:04, Ken Brown wrote:
> >>Yes, flags register corruption is exactly what Eli suggested in the other
> >>bug report I cited.
> >
> >The aforementioned patch was supposed to fix this problem and it is
> >definitely in the current 1.7.32 release...
>
> I didn't mean to suggest otherwise, just that perhaps a similar problem
> exists now.
>
> So I made the attached test case to explore that. Maybe I've made an
> obvious mistake with it, but on the face of it, it seems to demonstrate
> something...
>
> jon@tambora /
> $ gcc signal-stress.c -Wall -O0 -g
>
> jon@tambora /
> $ ./a
> failed: 2144210386 isn't equal to 2144210386, apparently
So it checks i and j for equality, fails, and then comes up with
"42 isn't equal to 42"? This is weird...
> Note there is some odd load dependency. For me, it works fine when it's the
> only thing running, but when I start up something CPU intensive, it often
> fails...
That's... interesting. I wonder if that only occurs in multi-core or
multi-CPU environments. The fact that i and j are not the same when
testing, but then are the same when printf is called looks like a
out-of-order execution problem.
Is it possible that we have to add CPU memory barriers to the sigdelayed
function to avoid stuff like this?
Corinna
> #include <assert.h>
> #include <sys/time.h>
> #include <signal.h>
> #include <stdio.h>
>
> long SmartScheduleInterval = 1; /* ms */
> long SmartScheduleTime = 0;
>
> static void
> SmartScheduleTimer(int sig)
> {
> if (sig != 0)
> SmartScheduleTime += SmartScheduleInterval;
> }
>
> void
> SmartScheduleStartTimer(void)
> {
> struct itimerval timer;
> timer.it_interval.tv_sec = 0;
> timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
> timer.it_value.tv_sec = 0;
> timer.it_value.tv_usec = SmartScheduleInterval * 1000;
> setitimer(ITIMER_REAL, &timer, 0);
> }
>
> int main()
> {
> /* Set up the timer signal function */
> struct sigaction act;
> act.sa_handler = SmartScheduleTimer;
> sigemptyset(&act.sa_mask);
> sigaddset(&act.sa_mask, SIGALRM);
> if (sigaction(SIGALRM, &act, 0) < 0) {
> perror("sigaction failed");
> return -1;
> }
>
> /* start timer */
> SmartScheduleStartTimer();
>
> /* Loop forever, doing tests which should always succeed, with lots of signals */
> int x = 0;
> int i = 0;
> while (1) {
> x = i;
> int j = x;
> if (j != i)
> {
> printf("failed: %d isn't equal to %d, apparently\n", i, j);
> break;
> }
> i++;
> }
> return 0;
> }
> --
> 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
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20141024/654ffbc8/attachment.sig>
More information about the Cygwin
mailing list