delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2024/10/07/09:12:31

DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 497DCUka3424197
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=pAPjV/xz
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A6D9D3858C78
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1728306748;
bh=o4jqLfvxOzObxGAul7UHmjMi2sQTRa8tdHOtL0zJGsM=;
h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:Cc:From;
b=pAPjV/xzZURRzwTEI/JE8e5ao8YuvbPXwacrTPbDFIfwrd2ROFecCL/7WfzmriSY7
j864YdMBcSNBN79mf0X8N7SC8DB9+HQUUG+EZqdXkyJrNlEAfddNX4VdY5gzkAo0iY
jpES6DJ60YzmY0McEDqdP7Lfl1BKAAOpbOWXYjQM=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B39BE3858D20
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B39BE3858D20
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728306726; cv=none;
b=WNY35KMWHc6Cj5gJp/EN7CTwj5QolT2MnfNCFnIMuLOvOtnHt3Ugn1vmakeHimP+jIMdE/7Gxt/222Tw8JwyzieuoXAGvbVAq5YBzpw83mbZxiPn3oIhmrtWOegW0t4Lo+3SNWPd0QoDVRmYgpT83GzhWTu8+iUEJM89psVsMEI=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1728306726; c=relaxed/simple;
bh=B0smcVdH932GJbvDxQzlSDbD2hGw35r5cArDXrEnX6c=;
h=From:Subject:To:Message-ID:Date:MIME-Version;
b=nj5qmt4GVQaqTIpbwWIrfg1vNxzFW2pqOHANCiWnVKQR1mAU8Ovmqb/QmlMIfXEx1gS0DpI5ghAYsbq3cqu0gB6U0hUcQyNipZ1KJ4MF08YOIez0QxIzueMm2/GkVBi2VKI3XSftVzLdhu+BgN1L/fSumCE0Aa6WK8AmVXdzRk8=
ARC-Authentication-Results: i=1; server2.sourceware.org
Subject: cygwin 3.5.4-1: signal handling destroys 'long double' values
To: cygwin AT cygwin DOT com
Message-ID: <922a6d7e-3ee1-9bb7-dfd7-b94c53a7b9d4@t-online.de>
Date: Mon, 7 Oct 2024 15:11:52 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
SeaMonkey/2.53.18.2
MIME-Version: 1.0
X-TOI-EXPURGATEID: 150726::1728306712-2D7F847E-AB9C4C02/0/0 CLEAN NORMAL
X-TOI-MSGID: 532c8257-8124-4fb3-9067-730f75a4ef02
X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, BODY_8BITS,
FREEMAIL_FROM, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,
SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Christian Franke via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Christian Franke <Christian DOT Franke AT t-online DOT de>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 497DCUka3424197

Recently I used 'stress-ng --class compute ...' which reported the 
failure of the 'logmath clogl' test. It could be reproduced with this 
loop which finishes after some random number of iterations:

$ while stress-ng --logmath 1 --logmath-method clogl -t 1; do echo OK; done
stress-ng: info:  [6190] setting to a 1 sec run per stressor
...
stress-ng: info:  [6190] successful run completed in 1.37 sec
OK
...
OK
stress-ng: info:  [6198] setting to a 1 sec run per stressor
stress-ng: info:  [6198] dispatching hogs: 1 logmath
stress-ng: fail:  [6199] logmath: clogl does not match expected result
stress-ng: error: [6198] logmath: [6199] terminated with an error, exit 
status=2 (stressor failed)
...
stress-ng: info:  [6198] unsuccessful run completed in 1.37 sec

The value mismatch occurs at the very end when the test loop running 
clogl() is hit by the signal indicating timeout.


A closer look shows that the problem could also be reproduced without 
any external math function:

$ uname -r
3.5.4-1.x86_64

$ gcc --version
gcc (GCC) 12.4.0
...

$ cat sigtest.c
#include <signal.h>
#include <stdio.h>

static volatile sig_atomic_t sigcnt;

static void sigint_handler(int sig)
{
   (void)sig;
   sigcnt++;
}

#ifndef WORKS
typedef long double float_type;
#define FMT "La"
#else
typedef double float_type;
#define FMT "a"
#endif

int main()
{
   signal(SIGINT, sigint_handler);
   volatile float_type x = 0x1.23456789p+0;
   while (sigcnt < 42) {
     volatile float_type y = x;
     volatile float_type d = y - x;
     if (d != 0.0)
       printf("x = %" FMT ", y = %" FMT ", d = %" FMT "\n", x, y, d);
   }
}

$ gcc -o sigtest -O2 sigtest.c

$ ./sigtest > out.txt
(press ^C 42x :-)

$ sort out.txt | uniq -c
       3 x = 0x1.23456789p+0, y = -nan, d = -nan
       6 x = 0x1.23456789p+0, y = 0x1.23456789p+0, d = -nan
      33 x = 0x1.23456789p+0, y = 0x1.23456789p+0, d = 0x0p+0

The problem also occurs if compiled without -O2, but less often. No 
problem occurs if compiled with -DWORKS which suggests that only 'long 
double' is affected.

-- 
Regards,
Christian


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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019