delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/06/25/16:52:23

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:content-type
:content-transfer-encoding:mime-version; q=dns; s=default; b=ghL
fe3T92fQYDlvpxOu4g9b/ADkyzEdyOB8kA7DVf/L9YUNQvZTaRMhtVw1iqN72ii8
pCpEogXhRX/ZIqPX/Lnkz2yefLrFu1L81qCNVFUCDh5LM9w1ggJkVtfZ1LhRf3J4
4TgWGbBhOuXZAXRXP4RGa/Rs1iO5TvOG/31uajg4=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:content-type
:content-transfer-encoding:mime-version; s=default; bh=gYVaPY0cw
dpoYWNph0erLdm08C8=; b=yoWxoCiQbj9lXiQlAyicOHkd2On03E5y7aRtYXsiE
4MPxF/6f+QRdTHg/7YRPRo3TsKy6TuNVZq5Q2OnD6WA6zjBivXhVLsLu9qeEcSKB
88S0gW5UG+xMLbh0sPp1TNZCQaiS7rasLGZN4aBeG7v2TUwHcL9DAhkSLTeDw6Ex
u8=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 spammy=contractor, H*MI:outlook, Contractor, H*MI:prod
X-HELO: nihcesxway2.hub.nih.gov
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nih.onmicrosoft.com; s=selector1-ncbi-nlm-nih-gov; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LrwA6IRB0/ysTIJN8VOAi8ISJATOfe+NX5LiqarKONg=; b=UJYnKZBgYvDRJsiWE36KGDhnd1rbEx53bBayPIDjHvNn0WAG5LaNwWH74ZSnzHr1y7vLeWUHuF86vvCrRQWDdYCsdKPacq845ZI7DKn5N1PfO9FNWkYZ6l/i3Z2MuuoeRLVqkk6n3FOZvE5oJwQjhgrS5DYbV7lAKNuAaaLG3GA=
From: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr AT ncbi DOT nlm DOT nih DOT gov>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: FPE_FLTSUB where FLT_FLTINV is expected
Date: Mon, 25 Jun 2018 20:51:53 +0000
Message-ID: <CY4PR09MB13023B702E15095F7217A729A54A0@CY4PR09MB1302.namprd09.prod.outlook.com>
authentication-results: spf=none (sender IP is ) smtp.mailfrom=lavr AT ncbi DOT nlm DOT nih DOT gov;
MIME-Version: 1.0
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id w5PKqLjw015560

Hello,

The following code produces FPE_FLTSUB(22) for the signal code whereas all platforms (Linux, Mac, FreeBSD) where I tested it, consistently yield FPE_FLTINV
(which on CYGWIN has a value of 21):

#define _GNU_SOURCE
#include <fenv.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

void sigfpe(int signo, siginfo_t* si, void* ucontext)
{
    printf("code = %d\n", si->si_code);
    _exit(255);
}

int main()
{
    double a = 0, b = 0;
    struct sigaction sa;
    memset(&sa, 0, sizeof(sa));
    sa.sa_sigaction = sigfpe;
    sa.sa_flags = SA_SIGINFO;
    sigaction(SIGFPE, &sa, 0);
    feenableexcept(FE_ALL_EXCEPT);
    printf("%lf", a / b);
    return 0;
}

I suppose that this block of code in exceptions.cc is not particularly correct, and only the last case (STACK_CHECK) actually pertains to the FLTSUB situation,
while all previous labels should be redirected to FPE_FLTINV (which, BTW, seems not being used at all in CYGWIN):

    case STATUS_FLOAT_DENORMAL_OPERAND:
    case STATUS_FLOAT_DIVIDE_BY_ZERO:
    case STATUS_FLOAT_INVALID_OPERATION:
    case STATUS_FLOAT_STACK_CHECK:
      si.si_signo = SIGFPE;
      si.si_code = FPE_FLTSUB;
      break;

Thanks for looking into this!

Regards,

Anton Lavrentiev
Contractor NIH/NLM/NCBI


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


- Raw text -


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