Bug 76396 - pthread_cleanup_push() misses a closing brace
pthread_cleanup_push() misses a closing brace
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
7.3
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-10-21 07:07 EDT by Oleg Goldshmidt
Modified: 2016-11-24 10:25 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-10-21 07:07:52 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Oleg Goldshmidt 2002-10-21 07:07:46 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020513

Description of problem:
pthread.h as shipped with glibc-devel-2.2.5-40 has an obvious bug:

#define pthread_cleanup_push(routine,arg) \
  { struct _pthread_cleanup_buffer _buffer;				      \
    _pthread_cleanup_push (&_buffer, (routine), (arg));

does not contain a closing brace, which causes compilation of any program
attempting to use pthread_cleanup_push() to fail.

Version-Release number of selected component (if applicable):

glibc-devel-2.2.5-40

How reproducible:
Always

Steps to Reproduce:
/* foo.c */

#include <stdio.h>
#include <pthread.h>

void my_cleanup(void *arg)
{
	printf("cleaning up %p\n",arg);
}

void register_cleaner(void *arg)
{
	pthread_cleanup_push(my_cleanup,arg);
}



	

Actual Results:

$ gcc -c foo.c
foo.c: In function `register_cleaner':
foo.c:13: parse error at end of input


Additional info:

I have not checked whether this exists in the latest glibc-2.3.1.
Comment 1 Jakub Jelinek 2002-10-21 07:18:05 EDT
That's on purpose, see comment above it:
   pthread_cleanup_push and pthread_cleanup_pop are macros and must always
   be used in matching pairs at the same nesting level of braces
or info libc:
   Matching pairs of `pthread_cleanup_push' and `pthread_cleanup_pop'
must occur in the same function, at the same level of block nesting.
Actually, `pthread_cleanup_push' and `pthread_cleanup_pop' are macros,
and the expansion of `pthread_cleanup_push' introduces an open brace
`{' with the matching closing brace `}' being introduced by the
expansion of the matching `pthread_cleanup_pop'.
Comment 2 Oleg Goldshmidt 2002-10-21 07:31:01 EDT
Indeed. My mistake. Had to RTFM. Sorry.

Note You need to log in before you can comment on or make changes to this bug.