public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix __fork
@ 2002-06-18 15:01 Jakub Jelinek
  2002-06-20 15:46 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2002-06-18 15:01 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

The following program hangs:

#include <stdlib.h>
#include <pthread.h>

void *
thread_func (void *arg)
{
  return 0;
}

int
main (int argc, char **argv)
{
  pthread_t thread;

  pthread_create (&thread, 0, thread_func, 0);
  system ("/bin/echo Hello, world!");
  return 0;
}

the reason is that some libc.so PLT removal got too far, particularly
we need to call fork/__fork from libpthread in threaded programs.

Here is a patch which backs out the __fork -> __fork_internal
changes and makes the above testcase work.

I wonder if read, write, open, close, sendto, recvfrom, select, etc.
(and their __* counterparts) called from glibc don't have to go to
libpthread too, because otherwise if they block they will not be
cancellation points. For open/close I think we can guess that they
will not block if we are not opening some device, but for the rest they
will probably block.

2002-06-18  Jakub Jelinek  <jakub@redhat.com>

	* include/unistd.h (__fork_internal): Remove.
	(__fork): Don't define to __fork_internal.
	* sysdeps/mach/hurd/fork.c (__fork): Remove INTDEF.
	* sysdeps/unix/sysv/aix/fork.c (__fork): Likewise.
	* sysdeps/unix/sysv/linux/ia64/fork.S (__fork_internal): Remove
	alias.
	* sysdeps/unix/sysv/linux/sparc/fork.S (__fork_internal): Likewise.
	* sysdeps/unix/sysv/linux/syscalls.list (__fork_internal): Likewise.

--- libc/include/unistd.h.jj	Tue Apr 30 15:15:00 2002
+++ libc/include/unistd.h	Tue Jun 18 23:50:14 2002
@@ -92,7 +92,6 @@ extern ssize_t __write (int __fd, __cons
 extern ssize_t __write_internal (int __fd, __const void *__buf, size_t __n)
      attribute_hidden;
 extern __pid_t __fork (void);
-extern __pid_t __fork_internal (void) attribute_hidden;
 extern int __getpagesize (void) __attribute__ ((__const__));
 extern int __getpagesize_internal (void)
      __attribute__ ((__const__)) attribute_hidden;
@@ -120,7 +119,6 @@ extern void __libc_check_standard_fds (v
 #ifndef NOT_IN_libc
 # define __close(fd) INTUSE(__close) (fd)
 # define __dup2(fd, fd2) INTUSE(__dup2) (fd, fd2)
-# define __fork() INTUSE(__fork) ()
 # define __getpagesize() INTUSE(__getpagesize) ()
 # define __getpgid(pid) INTUSE(__getpgid) (pid)
 # define __getpid() INTUSE(__getpid) ()
--- libc/sysdeps/mach/hurd/fork.c.jj	Tue Apr 30 12:54:57 2002
+++ libc/sysdeps/mach/hurd/fork.c	Tue Jun 18 23:50:53 2002
@@ -677,5 +677,4 @@ __fork (void)
   return err ? __hurd_fail (err) : pid;
 }
 
-INTDEF(__fork)
 weak_alias (__fork, fork)
--- libc/sysdeps/unix/sysv/aix/fork.c.jj	Tue Apr 30 12:56:36 2002
+++ libc/sysdeps/unix/sysv/aix/fork.c	Tue Jun 18 23:51:10 2002
@@ -25,5 +25,4 @@ __fork (void)
 {
   return kfork ();
 }
-INTDEF(__fork)
 strong_alias (__fork, fork)
--- libc/sysdeps/unix/sysv/linux/ia64/fork.S.jj	Tue Apr 30 12:56:54 2002
+++ libc/sysdeps/unix/sysv/linux/ia64/fork.S	Tue Jun 18 23:47:44 2002
@@ -37,6 +37,5 @@ ENTRY(__libc_fork)
 	ret
 PSEUDO_END(__libc_fork)
 
-strong_alias (__libc_fork, __fork_internal)
 weak_alias (__libc_fork, __fork)
 weak_alias (__libc_fork, fork)
--- libc/sysdeps/unix/sysv/linux/sparc/fork.S.jj	Wed Jun  5 10:27:57 2002
+++ libc/sysdeps/unix/sysv/linux/sparc/fork.S	Tue Jun 18 23:47:22 2002
@@ -25,6 +25,5 @@ PSEUDO (__libc_fork, fork, 0)
 	 and	%o0, %o1, %o0
 PSEUDO_END (__libc_fork)
 
-strong_alias (__libc_fork, __fork_internal)
 weak_alias (__libc_fork, __fork)
 weak_alias (__libc_fork, fork)
--- libc/sysdeps/unix/sysv/linux/syscalls.list.jj	Thu Jun  6 23:28:17 2002
+++ libc/sysdeps/unix/sysv/linux/syscalls.list	Tue Jun 18 23:51:41 2002
@@ -8,7 +8,7 @@ create_module	EXTRA	create_module	3	crea
 delete_module	EXTRA	delete_module	3	delete_module
 fdatasync	-	fdatasync	i:i	fdatasync
 flock		-	flock		i:ii	__flock		flock
-fork		-	fork		i:	__libc_fork	__fork fork __fork_internal
+fork		-	fork		i:	__libc_fork	__fork fork
 get_kernel_syms	EXTRA	get_kernel_syms	i:p	get_kernel_syms
 getegid		-	getegid		i:	__getegid	getegid
 geteuid		-	geteuid		i:	__geteuid	geteuid


	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix __fork
  2002-06-18 15:01 [PATCH] Fix __fork Jakub Jelinek
@ 2002-06-20 15:46 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2002-06-20 15:46 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

[-- Attachment #1: Type: text/plain, Size: 1271 bytes --]

On Tue, 2002-06-18 at 15:01, Jakub Jelinek wrote:

> I wonder if read, write, open, close, sendto, recvfrom, select, etc.
> (and their __* counterparts) called from glibc don't have to go to
> libpthread too, because otherwise if they block they will not be
> cancellation points.

No, that's fine.  All functions which internally might be using any of
these functions are *possible* cancellation points.  Nothing wrong with
not doing this.  It was a deliberate change to not allow cancellation
anymore.


> 2002-06-18  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* include/unistd.h (__fork_internal): Remove.
> 	(__fork): Don't define to __fork_internal.
> 	* sysdeps/mach/hurd/fork.c (__fork): Remove INTDEF.
> 	* sysdeps/unix/sysv/aix/fork.c (__fork): Likewise.
> 	* sysdeps/unix/sysv/linux/ia64/fork.S (__fork_internal): Remove
> 	alias.
> 	* sysdeps/unix/sysv/linux/sparc/fork.S (__fork_internal): Likewise.
> 	* sysdeps/unix/sysv/linux/syscalls.list (__fork_internal): Likewise.

I've applied this patch now.  Thanks,

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-06-20 22:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-18 15:01 [PATCH] Fix __fork Jakub Jelinek
2002-06-20 15:46 ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).