Bug 76396 - pthread_cleanup_push() misses a closing brace
Summary: pthread_cleanup_push() misses a closing brace
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 7.3
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-10-21 11:07 UTC by Oleg Goldshmidt
Modified: 2016-11-24 15:25 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-10-21 11:07:52 UTC
Embargoed:


Attachments (Terms of Use)

Description Oleg Goldshmidt 2002-10-21 11:07:46 UTC
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 11:18:05 UTC
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 11:31:01 UTC
Indeed. My mistake. Had to RTFM. Sorry.


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