This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] tests: don't assume getdtablesize () <= 10000000


On 09/25/2013 10:25 AM, Eric Blake wrote:
> On 09/25/2013 09:04 AM, Christopher Faylor wrote:
>>
>> Since you've previously made modifications in this area, why not supply
>> a simple patch?
> 
> Ah - the joys of having write access.  Yes, I'll post a patch for
> discussion.

What am I getting myself into?

$ cat foo.c
#include <stdio.h
#include <unistd.h>
int main(int argc, char **argv) {
  printf ("%d ", getdtablesize());
  if (argc > 1)
    printf ("%d ", dup2 (0, getdtablesize() - 1));
  printf ("%d\n", dup2 (0, getdtablesize()));
  return 0;
}
$ gcc -o foo -Wall -g foo.c
$ ./foo
Segmentation fault (core dumped)
$ strace -o /dev/null ./foo
256 256

Heisenbug!  The very act of trying to trace it makes it disappear :(

$ ./foo 1
Segmentation fault (core dumped)
$ strace -o /dev/null ./foo 1
  22687 [main] foo 2020 open_stackdumpfile: Dumping stack trace to
foo.exe.stackdump

probably some off-by-one at a boundary case, but not as simple as I had
originally hoped it would be.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]