Cygwin IPC - ftok() returns negative values - Bug Report
Stanisław Wawszczak
stanislaw.wawszczak@iscg.pl
Wed Jun 29 17:16:00 GMT 2016
Dear Corinna,
I am sorry about confusing you.
Simply:
----------------------------- Issue ------------------------------------
Call to ftok() returns negative value
----------------------------- Conditions -----------------------------
Windows 2012 R2 with latest patches
Cygwin x64 installed from exe installer got two weeks ago
$ cygcheck -V
cygcheck (cygwin) 2.5.2
System Checker for Cygwin
Copyright (C) 1998 - 2016 Cygwin Authors
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
----------------------------- Test case -------------------------------
#include <sys/ipc.h>
#include <stdio.h>
int main(int argc, char**argv)
{
key_t semHandle = ftok("/etc/fstab", 'A');
printf("started\n");
if(semHandle <= 0)
{
printf("semHandle <= 0 ; (semHandle = %lld)\n", semHandle);
}
else
{
printf("semHandle > 0 ; (semHandle = %lld)\n", semHandle);
}
printf("finished\n");
return 0;
}
--------------------------- Result -----------------------------------
$ ./test.exe
started
semHandle <= 0 ; (semHandle = -5833568887996598975)
finished
Pozdrawiam/Best Regards,
Stanisław Wawszczak
Architekt Systemowy
ISCG Sp. z o.o.
Poland
-----Original Message-----
From: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com] On Behalf Of Corinna Vinschen
Sent: Wednesday, June 29, 2016 5:15 PM
To: cygwin@cygwin.com
Subject: Re: Cygwin IPC - ftok() returns negative values - Bug Report
On Jun 29 13:14, Stanisław Wawszczak wrote:
> Dear All,
>
> I have had to compile sblim-sfcbd-1.4.10 on Cygwin. It is using IPC semaphores.
> Unfortunately it is returning wrong value as the result of complicated bit-wise logical operations.
> I have tried to “hack the system” and make multiplication of returned
> value by -1, but it triggers error in semget()
> Environment:
> Windows 2012 R2 with latest patches
> I have installed Cygwin from official installer couple days ago.
>
> I have attached the gdb session from such invocation. You can see the path and id in arguments are correct and stat() function returns correct values.
> Finally result in %rax is negative:
> rax 0xaf0b000701cc1d53 -5833568862233420461
Ok, but what's the exact problem? Following a GDB session is kind of a lot of work. Simple, very short, self-contained testcase, perhaps?
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
More information about the Cygwin
mailing list