Bug 23543 - when linked without -lpthread, sem_timedwait will be fail
Summary: when linked without -lpthread, sem_timedwait will be fail
Status: RESOLVED DUPLICATE of bug 20489
Alias: None
Product: glibc
Classification: Unclassified
Component: nptl (show other bugs)
Version: 2.30
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-17 09:10 UTC by hehongjun
Modified: 2018-08-20 07:10 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
call sem_timedwait failed (476 bytes, text/x-csrc)
2018-08-17 09:10 UTC, hehongjun
Details

Note You need to log in before you can comment on or make changes to this bug.
Description hehongjun 2018-08-17 09:10:55 UTC
Created attachment 11191 [details]
call sem_timedwait failed

when act like below:
1. calling sem_timedwait in shared lib, and the shrared lib linked without -lpthread;
2. the main program linked with -lptherad;
then, the sem_timedwait is failed.

this happend on x86 and mips.
 
the sample:
sem_mai.c
#include <stdio.h>

extern void testsem();

int main()
{
  printf("=== main start\n");
  testsem();
  printf("=== end\n");
}
Comment 1 Florian Weimer 2018-08-17 12:01:05 UTC
See bug 20489 comment 16.  Objects need to be linked at the right library, or otherwise the symbol version information will be missing.

*** This bug has been marked as a duplicate of bug 20489 ***
Comment 2 hehongjun 2018-08-20 01:04:02 UTC
(In reply to Florian Weimer from comment #1)
> See bug 20489 comment 16.  Objects need to be linked at the right library,
> or otherwise the symbol version information will be missing.
> 
> *** This bug has been marked as a duplicate of bug 20489 ***

  sometimes, we hope the DSO haveing no the symbol version, then it can run on different environment.
  I think the  sem_timedwait need to  fix.
  the reason are:
  1. the compatibility sem_init use old_sem structure;
  2. the sem_timedwait use new_sem structure;
  3. in https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/nptl/internaltypes.h;h=7c0d2402a3a68eec0b9849e4b6b52287f65d3f54;hb=042e1521c794a945edc43b5bfa7e69ad70420524, the new_sem have changed. Wait flag bit has be added to the value field.
  so, the sem_timedwait needs compatibility version symbol useing old_sem structure.
Comment 3 Florian Weimer 2018-08-20 07:10:35 UTC
Sorry, the DSO is simply broken.  It is quite literally calling the wrong function.