Modify

Opened 9 years ago

Closed 6 years ago

Last modified 4 years ago

#4809 closed defect (wontfix)

uClibc daemon/pthred fix (need on 0.9.29 and 0.9.30)

Reported by: Luigi 'Comio' Mantellini <luigi.mantellini@…> Owned by: nbd
Priority: highest Milestone: Barrier Breaker 14.07
Component: toolchain Version:
Keywords: daemon uclibc Cc:

Description

Dear,

the last uclibc has a broken "daemon" function implementation. "daemon" calls a wrong "fork" function (libc instead linuxthreads version) breaking the pthread environment.

This trivial patch permits a correct linking with the pthread "fork" implementation making the daemon call usable also with the last uClibc.

Best regards,

luigi

Attachments (1)

fix-daemon-pthread.patch (1.2 KB) - added by Luigi 'Comio' Mantellini <luigi.mantellini@…> 9 years ago.

Download all attachments as: .zip

Change History (15)

Changed 9 years ago by Luigi 'Comio' Mantellini <luigi.mantellini@…>

comment:1 Changed 9 years ago by luigi.mantellini@…

This patch covers changes like: /changeset/13712.html and many other.

Let me say that the final solution is to switch to nptl (when it will be available... mena carmelo!)

ciao

luigi

comment:2 follow-up: Changed 9 years ago by olistudent

Are you sure that your patch fixes the problem. I tested with the simple test case from https://bugs.busybox.net/show_bug.cgi?id=193. But it still hangs.
Nevertheless your assumption seems to be correct that the wrong fork function is used. I replaced fork in daemon.c with fork and then it works for me.

I'm not using the OpenWRT toolchain. Perhaps this is the reason why your patch doesn't work for me?

comment:3 Changed 9 years ago by olistudent

Sorry, didn't use the preview function. I replaced fork() with __fork().

comment:4 follow-up: Changed 9 years ago by olistudent

  • libc/unistd/daemon.c

    old new  
    5454libc_hidden_proto(dup2) 
    5555libc_hidden_proto(setsid) 
    5656libc_hidden_proto(chdir) 
    57 libc_hidden_proto(fork) 
    5857 
    5958int daemon( int nochdir, int noclose ) 
    6059{ 
    6160       int fd; 
    6261 
    63        switch (fork()) { 
     62       switch (__fork()) { 
    6463               case -1: 
    6564                       return(-1); 
    6665               case 0: 
     
    7473 
    7574       /* Make certain we are not a session leader, or else we 
    7675        * might reacquire a controlling terminal */ 
    77        if (fork()) 
     76       if (__fork()) 
    7877               _exit(0); 
    7978 
    8079       if (!nochdir) 

comment:5 in reply to: ↑ 2 Changed 9 years ago by luigi.mantellini@…

Replying to olistudent:

Are you sure that your patch fixes the problem. I tested with the simple test case from https://bugs.busybox.net/show_bug.cgi?id=193. But it still hangs.

The real problem is that the pthread implementation is really ugly. I'm waiting for the last nptl implementation.

Nevertheless your assumption seems to be correct that the wrong fork function is used. I replaced fork in daemon.c with fork and then it works for me.

I debugged using the jtag interface and I checked the complete execution flow... discovering the issue.

I'm not using the OpenWRT toolchain. Perhaps this is the reason why your patch doesn't work for me?

may be.

comment:6 in reply to: ↑ 4 Changed 9 years ago by anonymous

I think that this is not a solution, because the pthread support is optional and you need to use a weak linking.

luigi

Replying to olistudent:

...

+ switch (fork()) {

...

}}}

comment:7 Changed 9 years ago by olistudent

Wondering why here is no reference to #4915...

I did further research on this topic and recognized that your patch fixes this problem for dynamic linked libpthread but not for static version. Can you confirm this?

comment:8 Changed 9 years ago by Luigi 'Comio' Mantellini <luigi.mantellini@…>

I'm using only dynamic libs. I'm sorry I cannot confirm.

A better solution may be to choose the correct fork implementation by means of #ifdef/#else/#endef construct.

best regards,

luigi

comment:9 Changed 9 years ago by nbd

fix added in r15344, static library issue still pending.
i don't think #ifdef would work, since the same daemon() implementation would be used for both pthread and non-pthread variants, thus can't really be separated.
no idea what a real solution would look like, though.

comment:10 Changed 8 years ago by thepeople

  • Owner changed from developers to nbd

comment:11 Changed 8 years ago by nbd

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

comment:12 Changed 6 years ago by mcy@…

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Hello,

The problem is still present in OpenWrt 10.03.1 for static linking. Is there any progress here? If you need me to do some tests, I would be happy to help.

Cheers,

Matteo

comment:13 Changed 6 years ago by jow

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

Try trunk with ntpl, we're not going to fix this for backfire. If you find this to be still an issue open a separate ticket.

comment:14 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

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


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

 
Note: See TracTickets for help on using tickets.