From: Ken Brown <kbrown@cornell.edu>
To: airplanemath <airplanemath@aol.com>, cygwin@cygwin.com
Subject: Re: cpp /usr/include/threads.h fails; modfl segfaults
Date: Sat, 29 Aug 2020 13:57:59 -0400 [thread overview]
Message-ID: <9f819e67-5476-ea48-a13f-f7a4b25d6e69@cornell.edu> (raw)
In-Reply-To: <02b16d2e-9d51-de58-807b-3b31b2565b59@aol.com>
On 8/29/2020 8:52 AM, airplanemath via Cygwin wrote:
> Hello,
>
> I have two reports. A brief description of the system:
> $ uname -a | sed "s/${HOSTNAME}/\${HOSTNAME}/g"
> CYGWIN_NT-10.0 ${HOSTNAME} 3.1.7(0.340/5/3) 2020-08-22 17:48 x86_64 Cygwin
In the future, please use two separate emails for two unrelated bug reports.
> The first report:
>
> $ cpp /usr/include/threads.h
> # 1 "/usr/include/threads.h"
> # 1 "<built-in>"
> # 1 "<command-line>"
> # 1 "/usr/include/threads.h"
> /usr/include/threads.h:30:10: fatal error: machine/_threads.h: No such
> file or directory
> 30 | #include <machine/_threads.h>
> | ^~~~~~~~~~~~~~~~~~~~
> compilation terminated.
>
> $ cygcheck -p machine/_threads.h
> Found 0 matches for machine/_threads.h
It looks like /usr/include/threads.h is a Newlib header that's intended for
RTEMS. Here's the commit where it was introduced:
commit c98d01ee0cbc6eb7bbca8f2cde4a46b90ded3784
Author: Jeff Johnston <jjohnstn@redhat.com>
Date: Tue Oct 13 17:52:34 2015 -0400
Import <threads.h> from latest FreeBSD.
- Move types and defines to
<machine/_threads.h> so that it can be customized per target.
* libc/include/threads.h: New.
* libc/sys/rtems/include/machine/_threads.h: Likewise.
There's no machine/_threads.h in the repository for any platform other than
RTEMS. My guess is that it shouldn't be included in the Cygwin distro.
> The second report:
>
> $ cat test.c
> #include <math.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main(int argc, char *argv[]) {
> long double a, b, c;
> char *num_end = NULL;
> a = b = c = 0.0L;
> if (argc != 2) {
> fprintf(stderr, "Usage: %s NUMBER\n", argv[0]);
> exit(1);
> }
> a = strtold(argv[1], &num_end);
> b = modfl(a, &c);
> printf("%Lf %Lf %Lf\n", a, b, c);
> return 0;
> }
>
> $ gcc -Og -ggdb -g3 -Wall -Wextra -std=c99 -pedantic test.c -o test.exe
>
> $ ./test.exe 123.456
> Segmentation fault (core dumped)
>
> $ gdb --args ./test.exe 123.456
> GNU gdb (GDB) (Cygwin 8.3.1-1) 8.3.1
> ...
> Reading symbols from ./test.exe...
> (gdb) break modfl
> (gdb) run
> Starting program: /home/Daniel/test.exe 123.456
> [New Thread 13960.0x3cf4]
> [New Thread 13960.0xbdc]
> [New Thread 13960.0x4028]
> [New Thread 13960.0x3224]
> [New Thread 13960.0x3810]
> [New Thread 13960.0x1ae4]
> [New Thread 13960.0x3714]
> [Thread 13960.0x4028 exited with code 3697672192]
> [Thread 13960.0x3714 exited with code 0]
>
> Thread 1 "test" hit Breakpoint 1, modfl (value=<optimized out>,
> iptr=iptr@entry=0xffffcbd0) at
> /usr/src/debug/cygwin-3.1.7-1/winsup/cygwin/math/modfl.c:16
> 16 asm ("subq $8, %%rsp\n"
> (gdb) step
> 38 if (iptr)
> (gdb) step
> 39 *iptr = int_part;
> (gdb) step
> 40 return (isinf (value) ? 0.0L : value - int_part);
> (gdb) step
> 0 [main] test 28439 cygwin_exception::open_stackdumpfile: Dumping
> stack trace to test.exe.stackdump
> [Thread 13960.0x3b5c exited with code 35584]
> [Thread 13960.0x1ae4 exited with code 35584]
> [Thread 13960.0x3810 exited with code 35584]
> [Thread 13960.0xbdc exited with code 35584]
> [Thread 13960.0x3cf4 exited with code 35584]
> [Inferior 1 (process 13960) exited with code 0105400]
> (gdb)
>
> isinf and isinfl both work just fine, so I'm not sure what's going on there.
I built a version of cygwin1.dll without optimization in the hopes of making
debugging easier, but the problem doesn't occur with that DLL. So this is
somehow tied up with optimization. BTW, isinf is a macro that expands to
__builtin_isinf_sign, again suggesting that optimization is involved.
That's as far as I can take it.
Ken
next prev parent reply other threads:[~2020-08-29 17:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <02b16d2e-9d51-de58-807b-3b31b2565b59.ref@aol.com>
2020-08-29 12:52 ` airplanemath
2020-08-29 17:57 ` Ken Brown [this message]
2020-08-29 21:41 ` [QUAR] " Eliot Moss
2020-08-30 16:11 ` Ken Brown
2020-08-30 18:21 ` Eliot Moss
2020-08-30 1:21 ` airplanemath
2020-08-30 2:56 ` Ken Brown
2020-08-30 6:23 ` ASSI
2020-08-30 20:07 ` Brian Inglis
2020-08-30 13:00 ` Corinna Vinschen
2020-08-30 19:21 ` airplanemath
2020-08-31 7:33 ` Corinna Vinschen
2020-08-30 20:39 ` Brian Inglis
2020-08-31 7:35 ` Corinna Vinschen
2020-08-31 15:37 ` Brian Inglis
2020-08-31 18:45 ` Corinna Vinschen
2020-08-31 19:24 ` Brian Inglis
2020-08-31 19:41 ` Corinna Vinschen
2020-09-01 17:28 ` Brian Inglis
2020-09-02 7:54 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9f819e67-5476-ea48-a13f-f7a4b25d6e69@cornell.edu \
--to=kbrown@cornell.edu \
--cc=airplanemath@aol.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).