Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#7994 closed defect (fixed)

sem_open in uClibc 0.9.32 with nptl support fails badly

Reported by: lasaine@… Owned by: developers
Priority: normal Milestone: Barrier Breaker 14.07
Component: toolchain Version: Trunk
Keywords: Cc:


I have a following setup:

  • Asus WL500gPv2
  • openwrt trunk r23104
  • target brcm47xx
  • binutils 2.19.1
  • gcc 4.3.3 with CodeSourcery enhancements
  • uClibc 0.9.32 (with nptl support)

When I try to run programs that try to create a named semaphore using sem_open they fail. And errno is set to strange values (each time different): like 2141234936 (0x7fa0a6f8). Looks like a pointer. I've attached a small program to reproduce the error, but also any test from (uclibc source)/test/nptl/ that uses sem_open will do.

Attachments (2)

sem-test.c (362 bytes) - added by lasaine@… 7 years ago.
sem_open test
0001-mips-fix-errno-setting-after-syscall.patch (3.1 KB) - added by Alexander Gordeev <lasaine@…> 7 years ago.
patch that fixes the error

Download all attachments as: .zip

Change History (10)

Changed 7 years ago by lasaine@…

sem_open test

comment:1 Changed 7 years ago by anonymous

Seems there are two separate problems with sem_open and errno because I've just seen the same behaviour with other programs, for example:
grep: /etc/fstab: Unknown error 4722832

Should I create a separate ticket for errno?

comment:2 Changed 7 years ago by lasaine@…

Some digging showed that the problem is with the flawed errno only. The code for sem_open includes:

  /* If the semaphore object has to exist simply open it.  */
  if ((oflag & O_CREAT) == 0 || (oflag & O_EXCL) == 0)
      fd = __libc_open (finalname,
			(oflag & ~(O_CREAT|O_ACCMODE)) | O_NOFOLLOW | O_RDWR);

      if (fd == -1)
	  /* If we are supposed to create the file try this next.  */
	  if ((oflag & O_CREAT) != 0 && errno == ENOENT)
	    goto try_create;

In my little test I pass O_CREAT flag only so it tries to first open file and then if it doesn't exist (errno == ENOENT) creates it. But errno is flawed so it just fails.

I still can't make gdb/gdbserver work on the target unfortunately.

Changed 7 years ago by Alexander Gordeev <lasaine@…>

patch that fixes the error

comment:3 Changed 7 years ago by Alexander Gordeev <lasaine@…>

Attached the patch that fixes the error. I've also sent it to uClibc mailing list directly. Hope it will get accepted upstream. Please add this patch to toolchain/uClibc/patches-0.9.32/ (BTW, other versions maybe affected too, I didn't check that) and close the bug.

comment:4 Changed 7 years ago by lasaine@…

The patch was accepted upstream, see commit 9a4c8a3f2c753f4cee4bcbe23d28e23bbdb99e40.

comment:5 Changed 7 years ago by jow

  • Resolution set to fixed
  • Status changed from new to closed

The currently used uClibc 0.9.32 git snapshot includes this fix.

comment:6 Changed 7 years ago by anonymous

  • Resolution fixed deleted
  • Status changed from closed to reopened

The openwrt repository still contains the outdated patch which makes the current uclibc build fail - please remove, atm it has to be done manually

comment:7 Changed 7 years ago by acoul

  • Resolution set to fixed
  • Status changed from reopened to closed

latest trunk is synced to uClibc-0.9.32 which builds fine.

comment:8 Changed 4 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

Add Comment

Modify Ticket

as closed .
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.