linking against librt doesn't provide sem_post

Bug #874418 reported by Gary Duzan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
manpages (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

We have software that uses semaphores but not pthreads. Therefore, our code links against librt, as documented in the sem_post man page. This worked fine in 10.04 and 11.04, but not in 11.10.

> cat a.c
#include <semaphore.h>
int main()
{
    sem_t *mysem;

    int ret;

    ret = sem_post(mysem);
    return 0;
}
> gcc -g -lrt -o a a.c
/tmp/ccUadHKv.o: In function `main':
a.c:8: undefined reference to `sem_post'
collect2: ld returned 1 exit status

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: libc6-dev 2.13-20ubuntu5
ProcVersionSignature: Ubuntu 3.0.0-12.20-generic 3.0.4
Uname: Linux 3.0.0-12-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 1.23-0ubuntu3
Architecture: amd64
Date: Fri Oct 14 12:30:58 2011
SourcePackage: eglibc
UpgradeStatus: Upgraded to oneiric on 2011-10-07 (6 days ago)

Revision history for this message
Gary Duzan (gary-duzan) wrote :
Revision history for this message
Matthias Klose (doko) wrote :
Changed in eglibc (Ubuntu):
status: New → Invalid
Revision history for this message
Gary Duzan (gary-duzan) wrote :

If this is going to be the case going forward, then the sem_* man pages should be updated to indicate that -lrt is no longer sufficient to use semaphores. I don't have a problem with the change since LSB says to use libpthread, anyway, but if the behavior is going to change then the documentation that suggests use of the old behavior should be changed.

Revision history for this message
Gary Duzan (gary-duzan) wrote :

The sem_* man pages need to be updated to reflect a "blessed" way of linking in semaphore code now that -lrt doesn't work.

affects: eglibc (Ubuntu) → manpages (Ubuntu)
Changed in manpages (Ubuntu):
status: Invalid → New
Revision history for this message
Matthias Klose (doko) wrote :

no, the manpages doesn't tell you about the order of objects

Changed in manpages (Ubuntu):
status: New → Invalid
Revision history for this message
Gary Duzan (gary-duzan) wrote :

True, but it does say that -lrt will work for semaphores, but now it doesn't.

Revision history for this message
Gary Duzan (gary-duzan) wrote :

Note that while the example I gave had the -lrt before the object, the same problem occurs if it is included at the end.

Revision history for this message
Michael Kerrisk (mtk-manpages) wrote :

So, it'd be good if someone had directed this to upstream man-pages. I found this bug report by chance. I've made appropriate changes for the upcoming man-pages-3.42.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.