delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/06/10/17:24:19

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:message-id:date:from:mime-version:to:subject
:content-type; q=dns; s=default; b=oB2ppRHHEIcBqtzfi0pPOBVCsuUy4
8mjBpg8G/j7Pjv8aU35tW5jMv7bq4z4oxxZ4iB4TAPlOHzIKU8TyYGYstsj3OWko
75g3vu7c/CiyyWU8ujBcuD5kcq5GJmq1ROJTDoYwwUaLjCaJCHsABoDXRPjq43Lj
KzvguUR6C4ZCjU=
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:message-id:date:from:mime-version:to:subject
:content-type; s=default; bh=EtulGnI4YiOZa7GJv2hS8qbADo0=; b=orp
Mmuw3OAl0+6QZWSnKY6k+CowMflfe3zbclau94LBXOJMai2MOTLbBMWfS3qXHTH6
rzAFLoyDY6YGxZmNCzt0SGC82TZ0lef8gwR1FlI5B95zBC00eosaK5Q+Iov3k/mZ
DdsZI8++73mvmLIkU1Hw5PvAvRumt/5TdaiUgaNU=
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
X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1
X-Trace: 866456347/mk-filter-2.mail.uk.tiscali.com/B2C/$THROTTLED_DYNAMIC/b2c-CUSTOMER-DYNAMIC-IP/85.210.76.171/None/drstacey AT tiscali DOT co DOT uk
X-SBRS: None
X-RemoteIP: 85.210.76.171
X-IP-MAIL-FROM: drstacey AT tiscali DOT co DOT uk
X-SMTP-AUTH:
X-Originating-Country: GB/UNITED KINGDOM
X-MUA: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6
X-IP-BHB: Once
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: ApoBAIlDtlFV0kyr/2dsb2JhbAANTIxUtw2EFj0WGAMCAQIBWAgBAa8tklSOEIFFg0oDjUyCNYEsjB+ORg
Message-ID: <51B643EF.6080806@tiscali.co.uk>
Date: Mon, 10 Jun 2013 22:23:59 +0100
From: David Stacey <drstacey AT tiscali DOT co DOT uk>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: semget() crash
X-Virus-Found: No

--------------020600040004070105040202
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Please find attached a short test programme derived from the semaphore 
handling code in Poco. The test crashes in the call to semget(), 
reporting 'Bad system call (core dumped)'. I am using the latest 32-bit 
snapshot (2013-06-08).

The test programme runs correctly under Fedora 18 x64.

BTW, the man page for ftok(3) states that the second parameter 
('proj_id') must be non-zero. Contrary to this, Poco uses zero for 
'proj_id'. This is easy enough to patch, but does anyone know the effect 
of using zero here? If there's no good reason for it then I'll raise a 
ticket with Poco and get it changed.

Many thanks in advance for looking at this problem,

Dave.


--------------020600040004070105040202
Content-Type: text/x-csrc;
 name="poco_ne.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="poco_ne.c"

/* Compile: gcc -o poco_ne poco_ne.c
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

/* Error handling. */
void FatalError(const char* const pmsg)
{
	fprintf(stderr, "%s\n", pmsg);
	exit(1);
}

int main()
{
	/* Create a file. */
	const char* const pfilename = "try.txt";
	int fd = open(pfilename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
	if (fd == -1)
		FatalError("open() failed.");
	close(fd);

	/* Generate a key, using the file we just created. */
	key_t key = ftok(pfilename, 'a');
	if (key == -1)
		FatalError("ftok() failed.");

	/* Get the semaphore set identifier */
	fprintf(stderr, "Trying semget()\n");
	fprintf(stderr, "This causes 'Bad system call (core dumped)' in Cygwin.\n");
	int semid = semget(key, 1, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | IPC_CREAT | IPC_EXCL);
	fprintf(stderr, "OK - that worked. semget() returned %i\n", semid);
	return 0;
}


--------------020600040004070105040202
Content-Type: text/plain; charset=us-ascii

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

- Raw text -


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