All of lore.kernel.org
 help / color / mirror / Atom feed
* [uml-devel] pthreads?
@ 2003-09-11 15:54 Geert Uytterhoeven
  2003-09-11 17:55 ` Jeff Dike
  2003-09-12  8:52 ` [uml-devel] pthreads? Gerd Knorr
  0 siblings, 2 replies; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-09-11 15:54 UTC (permalink / raw)
  To: User-mode Linux Kernel Development; +Cc: Geert Uytterhoeven

	Hi,

I'm working on a virtual frame buffer device for UML that displays in a GDK/GTK
window. The GDK/GTK frame buffer device works fine as a standalone application,
but when compiled into the kernel things get more challenging.

GTK needs GDK, X11, ..., and finally I need libpthread.

As soon as I link the final image with -lpthread (even if it's not
used/referenced anywhere else), the resulting image no longer boots, but hangs
very soon. This is easily reproducible by doing:

| tux$ gcc -Wl,-T,arch/um/uml.lds.s -static -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc -o linux arch/um/main.o vmlinux -L/usr/lib -lutil -lpthread
| tux$ ./linux
| Checking for the skas3 patch in the host...not found
| Checking for /proc/mm...not found
| capture_stack : Expected SIGSTOP, got status = 0xb7f
| tux$ ./linux debug
| Checking for the skas3 patch in the host...not found
| Checking for /proc/mm...not found
| capture_stack : Expected SIGSTOP, got status = 0xb7f
| tux$ 

Does anyone have a solution for this?

Perhaps I have to `wrap' some symbols from libpthread?
I noticed libpthread implements e.g. longjmp(), sigaction(), sigwait(), ...

Or don't link with libpthread and implement the required pthread functionality
myself in term of kernel threads and synchronization primitives? I seem to need
at least these:

    pthread_cond_init
    pthread_cond_destroy
    pthread_cond_broadcast
    pthread_cond_signal
    pthread_cond_timedwait
    pthread_cond_wait
    pthread_setspecific
    pthread_getspecific
    pthread_key_create
    pthread_mutex_init
    pthread_mutex_destroy
    pthread_mutex_lock
    pthread_mutex_trylock
    pthread_mutex_unlock
    pthread_equal

Thanks for your suggestions!

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] pthreads?
  2003-09-11 15:54 [uml-devel] pthreads? Geert Uytterhoeven
@ 2003-09-11 17:55 ` Jeff Dike
  2003-09-12  8:52 ` [uml-devel] pthreads? Gerd Knorr
  1 sibling, 0 replies; 32+ messages in thread
From: Jeff Dike @ 2003-09-11 17:55 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: User-mode Linux Kernel Development

geert@linux-m68k.org said:
> | capture_stack : Expected SIGSTOP, got status = 0xb7f 

This is the cloned thread segfaulting.  If you gdb it to that point, you
can grab the thread's registers and see what's happening.  Maybe the stack
is bogus and it segfaulted as soon as it tried to run.  That would be my
best guess.

				Jeff



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* [uml-devel] Re: pthreads?
  2003-09-11 15:54 [uml-devel] pthreads? Geert Uytterhoeven
  2003-09-11 17:55 ` Jeff Dike
@ 2003-09-12  8:52 ` Gerd Knorr
  2003-09-12  9:07   ` Geert Uytterhoeven
  1 sibling, 1 reply; 32+ messages in thread
From: Gerd Knorr @ 2003-09-12  8:52 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: user-mode-linux-devel

Geert Uytterhoeven <geert@linux-m68k.org> writes:

> I'm working on a virtual frame buffer device for UML that displays in a GDK/GTK
> window.

What is the point of using gdk?  I'd go with Xlib for that, if all you
need is just a X11 window to blit the vitual framebuffer to IMHO isn't
worth the trouble involved when using gdk/gtk.  You just don't need
all the fancy stuff provided by the toolkit ...

  Gerd

-- 
You have a new virus in /var/mail/kraxel


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* [uml-devel] Re: pthreads?
  2003-09-12  8:52 ` [uml-devel] pthreads? Gerd Knorr
@ 2003-09-12  9:07   ` Geert Uytterhoeven
  2003-09-12 11:08     ` Gerd Knorr
                       ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-09-12  9:07 UTC (permalink / raw)
  To: Gerd Knorr; +Cc: User-mode Linux Kernel Development

On 12 Sep 2003, Gerd Knorr wrote:
> Geert Uytterhoeven <geert@linux-m68k.org> writes:
> > I'm working on a virtual frame buffer device for UML that displays in a GDK/GTK
> > window.
> 
> What is the point of using gdk?  I'd go with Xlib for that, if all you
> need is just a X11 window to blit the vitual framebuffer to IMHO isn't
> worth the trouble involved when using gdk/gtk.  You just don't need
> all the fancy stuff provided by the toolkit ...

GdkRgb is nice for displaying pictures, without having to care about X server
visuals, etc. I.e. I need to write less code.  And I want a few buttons to
control the fbdev behavior.

BTW, it's libX11 that needs libpthread...

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* [uml-devel] Re: pthreads?
  2003-09-12  9:07   ` Geert Uytterhoeven
@ 2003-09-12 11:08     ` Gerd Knorr
  2003-09-12 11:18       ` Geert Uytterhoeven
  2003-09-12 11:18     ` Henrik Nordstrom
  2003-10-02  9:08     ` Jan Hudec
  2 siblings, 1 reply; 32+ messages in thread
From: Gerd Knorr @ 2003-09-12 11:08 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: User-mode Linux Kernel Development

> > What is the point of using gdk?  I'd go with Xlib for that, if all you
> > need is just a X11 window to blit the vitual framebuffer to IMHO isn't
> > worth the trouble involved when using gdk/gtk.  You just don't need
> > all the fancy stuff provided by the toolkit ...
> 
> GdkRgb is nice for displaying pictures, without having to care about X server
> visuals, etc. I.e. I need to write less code.

I would probably try to map the X11 ximage format directly into linux
framebuffer format, so you can use XPutImage() (or XShmPutImage()) to
display the virtual framebuffer memory without any conversions.

> And I want a few buttons to control the fbdev behavior.

Well, ok, at this point it becomes very ugly with plain Xlib.  What
stuff do you want control there?

> BTW, it's libX11 that needs libpthread...

Oops.  I'd expected it is one of the many gtk libs ...

  Gerd

-- 
You have a new virus in /var/mail/kraxel


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-12  9:07   ` Geert Uytterhoeven
  2003-09-12 11:08     ` Gerd Knorr
@ 2003-09-12 11:18     ` Henrik Nordstrom
  2003-09-12 16:28       ` Jeff Dike
  2003-10-02  9:08     ` Jan Hudec
  2 siblings, 1 reply; 32+ messages in thread
From: Henrik Nordstrom @ 2003-09-12 11:18 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Gerd Knorr, User-mode Linux Kernel Development

fre 2003-09-12 klockan 11.07 skrev Geert Uytterhoeven:

> GdkRgb is nice for displaying pictures, without having to care about X server
> visuals, etc. I.e. I need to write less code.  And I want a few buttons to
> control the fbdev behavior.
> 
> BTW, it's libX11 that needs libpthread...

What about running the X11 stuff in a helper and using mmap to map the
framebuffer data in both the UML and the helper process?

Regards
Henrik
-- 
Henrik Nordstrom <hno@marasystems.com>
MARA Systems AB



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* [uml-devel] Re: pthreads?
  2003-09-12 11:08     ` Gerd Knorr
@ 2003-09-12 11:18       ` Geert Uytterhoeven
  2003-09-12 12:15         ` Gerd Knorr
  0 siblings, 1 reply; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-09-12 11:18 UTC (permalink / raw)
  To: Gerd Knorr; +Cc: User-mode Linux Kernel Development

On Fri, 12 Sep 2003, Gerd Knorr wrote:
> > > What is the point of using gdk?  I'd go with Xlib for that, if all you
> > > need is just a X11 window to blit the vitual framebuffer to IMHO isn't
> > > worth the trouble involved when using gdk/gtk.  You just don't need
> > > all the fancy stuff provided by the toolkit ...
> > 
> > GdkRgb is nice for displaying pictures, without having to care about X server
> > visuals, etc. I.e. I need to write less code.
> 
> I would probably try to map the X11 ximage format directly into linux
> framebuffer format, so you can use XPutImage() (or XShmPutImage()) to
> display the virtual framebuffer memory without any conversions.
> 
> > And I want a few buttons to control the fbdev behavior.
> 
> Well, ok, at this point it becomes very ugly with plain Xlib.  What
> stuff do you want control there?

  - The rate at which the display is updated
  - The visual type (it's in fb_fix_screeninfo, so the user cannot specify it)
  - The frame buffer layout (it's in fb_fix_screeninfo), to e.g. debug code for
    bitplanes

So at first I want to start with chunky 8 bpp 640x480, but later I want to add
support for other pixel formats and visuals.

GdkRgb allows to easily draw 8 bpp pseudocolor or grayscale, and 24 or 32 bpp
RGB, and display it on whatever X server you have available.

> > BTW, it's libX11 that needs libpthread...
>
> Oops.  I'd expected it is one of the many gtk libs ...

Me too, but it proved to be different...

Right now I added dummies for the various needed pthread_* calls. The kernel
starts fine, but as soon as I make calls to GTK or GDK it breaks.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* [uml-devel] Re: pthreads?
  2003-09-12 11:18       ` Geert Uytterhoeven
@ 2003-09-12 12:15         ` Gerd Knorr
  2003-09-12 12:17           ` Geert Uytterhoeven
  0 siblings, 1 reply; 32+ messages in thread
From: Gerd Knorr @ 2003-09-12 12:15 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: User-mode Linux Kernel Development

>   - The rate at which the display is updated

Ok.

>   - The visual type (it's in fb_fix_screeninfo, so the user cannot specify it)
>   - The frame buffer layout (it's in fb_fix_screeninfo), to e.g. debug code for
>     bitplanes

Uh?  Can a fb driver change them without fbcon becoming greatly confused?  I think
it is in fix for a reason ...

> GdkRgb allows to easily draw 8 bpp pseudocolor or grayscale, and 24 or 32 bpp
> RGB, and display it on whatever X server you have available.

For debugging various modes that makes sense, althrough it probably
isn't exactly fast ...

  Gerd

-- 
You have a new virus in /var/mail/kraxel


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* [uml-devel] Re: pthreads?
  2003-09-12 12:15         ` Gerd Knorr
@ 2003-09-12 12:17           ` Geert Uytterhoeven
  0 siblings, 0 replies; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-09-12 12:17 UTC (permalink / raw)
  To: Gerd Knorr; +Cc: User-mode Linux Kernel Development

On Fri, 12 Sep 2003, Gerd Knorr wrote:
> >   - The visual type (it's in fb_fix_screeninfo, so the user cannot specify it)
> >   - The frame buffer layout (it's in fb_fix_screeninfo), to e.g. debug code for
> >     bitplanes
> 
> Uh?  Can a fb driver change them without fbcon becoming greatly confused?  I think
> it is in fix for a reason ...

You cannot change them immediately, but if the changes would take effect on the
next mode change it should work just fine.

> > GdkRgb allows to easily draw 8 bpp pseudocolor or grayscale, and 24 or 32 bpp
> > RGB, and display it on whatever X server you have available.
> 
> For debugging various modes that makes sense, althrough it probably
> isn't exactly fast ...

You'd be surprised. At work I wrote an emulator for the graphics of a Set Top
Box chip, which alpha blended various layers in different modes together.
Redraw was done only if a particular region of the screen was changed. It was
very usable, unless you drew individual pixels.

For UML and fbdev user space I have to update the whole screen at regular time
intervals, so it can be a bit slower. For UML and fbdev kernel space I can
update the screen when it's redrawn, thanks to James' new drawing primitives in
2.6.0.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-12 11:18     ` Henrik Nordstrom
@ 2003-09-12 16:28       ` Jeff Dike
  2003-09-12 22:25         ` Henrik Nordstrom
  2003-09-13 15:24         ` Geert Uytterhoeven
  0 siblings, 2 replies; 32+ messages in thread
From: Jeff Dike @ 2003-09-12 16:28 UTC (permalink / raw)
  To: Henrik Nordstrom
  Cc: Geert Uytterhoeven, Gerd Knorr, User-mode Linux Kernel Development

hno@marasystems.com said:
> What about running the X11 stuff in a helper and using mmap to map the
> framebuffer data in both the UML and the helper process? 

I'm not going to Geert how to do this, but I would like to see everything in 
one process.  The reason is that I have fond hopes of turning UML into a
library, libUML.so, which can be used by any app that needs anything provided
by the kernel.

So, if this is going to happen, libUML needs to be compatible with everything
else out there, and this is one step in that direction.

So, my preference would be to figure out what the incompatibility between
UML and pthreads is, and fix UML.  And I'll provide whatever help is needed
to sort this out.

				Jeff



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-12 16:28       ` Jeff Dike
@ 2003-09-12 22:25         ` Henrik Nordstrom
  2003-09-13 18:53           ` Jeff Dike
  2003-09-13 15:24         ` Geert Uytterhoeven
  1 sibling, 1 reply; 32+ messages in thread
From: Henrik Nordstrom @ 2003-09-12 22:25 UTC (permalink / raw)
  To: Jeff Dike
  Cc: Geert Uytterhoeven, Gerd Knorr, User-mode Linux Kernel Development

On Fri, 12 Sep 2003, Jeff Dike wrote:

> I'm not going to Geert how to do this, but I would like to see everything in 
> one process.  The reason is that I have fond hopes of turning UML into a
> library, libUML.so, which can be used by any app that needs anything provided
> by the kernel.

If you think it is feasible to run another heavy user of clone(), message
queues and signals in the same process then it might be.. but my gut
feeling is not..

> So, if this is going to happen, libUML needs to be compatible with everything
> else out there, and this is one step in that direction.

The use of helpers does not exclude the other.. but I see your point.

Regards
enrik



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-12 16:28       ` Jeff Dike
  2003-09-12 22:25         ` Henrik Nordstrom
@ 2003-09-13 15:24         ` Geert Uytterhoeven
  2003-09-13 18:54           ` Jeff Dike
  1 sibling, 1 reply; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-09-13 15:24 UTC (permalink / raw)
  To: Jeff Dike; +Cc: User-mode Linux Kernel Development

On Fri, 12 Sep 2003, Jeff Dike wrote:
> hno@marasystems.com said:
> > What about running the X11 stuff in a helper and using mmap to map the
> > framebuffer data in both the UML and the helper process? 
> 
> I'm not going to Geert how to do this, but I would like to see everything in 
> one process.  The reason is that I have fond hopes of turning UML into a
> library, libUML.so, which can be used by any app that needs anything provided
> by the kernel.
> 
> So, if this is going to happen, libUML needs to be compatible with everything
> else out there, and this is one step in that direction.
> 
> So, my preference would be to figure out what the incompatibility between
> UML and pthreads is, and fix UML.  And I'll provide whatever help is needed
> to sort this out.

I compiled my own libpthreads, so I can easily remove code from it and see what
happens.

First step: libpthread redefines sigaction to install its own signal handler
around the signal. If I remove this, UML runs until:

| Initializing stdio console driver

and quits without any further messages. If I try to run it under gdb, gdb
crashes immediately with a segmentation fault.

I'll be doing some more digging...

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-12 22:25         ` Henrik Nordstrom
@ 2003-09-13 18:53           ` Jeff Dike
  2003-09-13 21:01             ` Henrik Nordstrom
  0 siblings, 1 reply; 32+ messages in thread
From: Jeff Dike @ 2003-09-13 18:53 UTC (permalink / raw)
  To: Henrik Nordstrom
  Cc: Geert Uytterhoeven, Gerd Knorr, User-mode Linux Kernel Development

hno@marasystems.com said:
> If you think it is feasible to run another heavy user of clone(),
> message queues and signals in the same process then it might be.. but
> my gut feeling is not.. 

The only thing that worries me about clone is wait().  wait(-1, ...) is 
obviously dangerous if there are children floating around that you don't
know about.  Any properly careful user of wait will call it with the pids
of children that it knows about.  UML is not properly careful...

Signals can be handled cleanly if handlers are chained.

I don't know what message queues are.  UML doesn't use anything by that name.

However, I didn't think of the possibility of pthreads overriding system calls.
That opens up whole new vistas of brokenness.

				Jeff



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-13 15:24         ` Geert Uytterhoeven
@ 2003-09-13 18:54           ` Jeff Dike
  2003-09-15  6:57             ` Geert Uytterhoeven
  0 siblings, 1 reply; 32+ messages in thread
From: Jeff Dike @ 2003-09-13 18:54 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: User-mode Linux Kernel Development

geert@linux-m68k.org said:
> First step: libpthread redefines sigaction to install its own signal
> handler around the signal.

Gawd, that's unpleasant.  What does its signal handler do?

> and quits without any further messages. If I try to run it under gdb,
> gdb crashes immediately with a segmentation fault. 

Try stracing it.  You can tell a lot about its progress by looking at its 
system calls.

				Jeff



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-13 18:53           ` Jeff Dike
@ 2003-09-13 21:01             ` Henrik Nordstrom
  0 siblings, 0 replies; 32+ messages in thread
From: Henrik Nordstrom @ 2003-09-13 21:01 UTC (permalink / raw)
  To: Jeff Dike; +Cc: Geert Uytterhoeven, User-mode Linux Kernel Development

On Sat, 13 Sep 2003, Jeff Dike wrote:

> However, I didn't think of the possibility of pthreads overriding system calls.
> That opens up whole new vistas of brokenness.

It doesn't override system calls from what I know, but it does replace a 
whole lot of the glibc calls, some of which have the same name as some of 
the system calls.. (open, close, read, write, fcntl, recvmsg, sendmgs, 
sigaction, wait, waitpid, malloc, free and a whole lot more).

Regards
Henrik



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-13 18:54           ` Jeff Dike
@ 2003-09-15  6:57             ` Geert Uytterhoeven
  2003-09-15  9:19               ` Henrik Nordstrom
  0 siblings, 1 reply; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-09-15  6:57 UTC (permalink / raw)
  To: Jeff Dike; +Cc: User-mode Linux Kernel Development

On Sat, 13 Sep 2003, Jeff Dike wrote:
> geert@linux-m68k.org said:
> > First step: libpthread redefines sigaction to install its own signal
> > handler around the signal.
> 
> Gawd, that's unpleasant.  What does its signal handler do?

For reference, here's the code (from Debian glibc_2.3.1-16):

| /* The wrapper around sigaction.  Install our own signal handler
|    around the signal. */
| int __sigaction(int sig, const struct sigaction * act,
|               struct sigaction * oact)
| {
|   struct sigaction newact;
|   struct sigaction *newactp;
| 
|   if (sig == __pthread_sig_restart ||
|       sig == __pthread_sig_cancel ||
|       (sig == __pthread_sig_debug && __pthread_sig_debug > 0))
|     {
|       __set_errno (EINVAL);
|       return -1;
|     }
|   if (act)
|     {
|       newact = *act;
|       if (act->sa_handler != SIG_IGN && act->sa_handler != SIG_DFL
|           && sig > 0 && sig < NSIG)
|         {
|           if (act->sa_flags & SA_SIGINFO)
|             newact.sa_handler = (__sighandler_t) __pthread_sighandler_rt;
|           else
|             newact.sa_handler = (__sighandler_t) __pthread_sighandler;
|         }
|       newactp = &newact;
|     }
|   else
|     newactp = NULL;
|   if (__libc_sigaction(sig, newactp, oact) == -1)
|     return -1;
|   if (sig > 0 && sig < NSIG)
|     {
|       if (oact != NULL
|           /* We may have inherited SIG_IGN from the parent, so return the
|              kernel's idea of the signal handler the first time
|              through.  */
|           && (__sighandler_t) __sighandler[sig].old != SIG_ERR)
|         oact->sa_handler = (__sighandler_t) __sighandler[sig].old;
|       if (act)
|         /* For the assignment it does not matter whether it's a normal
|            or real-time signal.  */
|         __sighandler[sig].old = (arch_sighandler_t) act->sa_handler;
|     }
|   return 0;
| }
| #if 0 // FIXME UML sigaction
|     // FIXME: causes problems with UML
|     //   Checking for the skas3 patch in the host...found
|     //   Checking for /proc/mm...found
|     //   capture_stack : Expected SIGSTOP, got status = 0xb7f
| 
| strong_alias(__sigaction, sigaction)
| #endif // FIXME UML

As you can see, I have to uncomment the strong_alias(...) to make UML boot.

> > and quits without any further messages. If I try to run it under gdb,
> > gdb crashes immediately with a segmentation fault. 
> 
> Try stracing it.  You can tell a lot about its progress by looking at its 
> system calls.

Didn't help much neither...

I removed all libpthread overridings of symbols that are used by UML
(intersection of 'U' symbols of vmlinux and 'T' and 'W' symbols of libpthread),
and now UML boots. I'll try to find out which one is the bad guy...

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-15  6:57             ` Geert Uytterhoeven
@ 2003-09-15  9:19               ` Henrik Nordstrom
  2003-09-15  9:28                 ` Geert Uytterhoeven
  2003-10-02  9:20                 ` Jan Hudec
  0 siblings, 2 replies; 32+ messages in thread
From: Henrik Nordstrom @ 2003-09-15  9:19 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Jeff Dike, User-mode Linux Kernel Development

On Mon, 15 Sep 2003, Geert Uytterhoeven wrote:

> On Sat, 13 Sep 2003, Jeff Dike wrote:
> > geert@linux-m68k.org said:
> > > First step: libpthread redefines sigaction to install its own signal
> > > handler around the signal.
> > 
> > Gawd, that's unpleasant.  What does its signal handler do?
> 
> For reference, here's the code (from Debian glibc_2.3.1-16):

The interesting part is what the signal handler does, not how it is
installed.  According to the code you quoted the signal handler is
__pthread_signhandler or __pthread_sighandler_rt depending on the
sigaction type.

From my understanding of ptherads but without reading the code this signal
handler is supposed to route the signal to the correct threads. Linux
kernel signal management in cloned processes differs significantly from
POSIX Threads signal specification and this signal routing tries to make
Linux look more like the POSIX Threads specification.

> I removed all libpthread overridings of symbols that are used by UML
> (intersection of 'U' symbols of vmlinux and 'T' and 'W' symbols of libpthread),
> and now UML boots. I'll try to find out which one is the bad guy...

In this case I would say UML is one of the bad guys due to it's symbols
which overrides libc or pthreads. Any application which needs to override
libc primitives to work is a bad guy and pthreads is technically part of
libc when using threaded applications.

Hoever, if UML uses clone() or other libc calls (yes, clone() is a libc
call, direcly matched by a kernel syscall) in a manner which should not
confuse other users of the same calls then pthreads may be a bad guy as
well, not dealing properly with the situation.

Regards
Henrik



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-15  9:19               ` Henrik Nordstrom
@ 2003-09-15  9:28                 ` Geert Uytterhoeven
  2003-09-15 10:51                   ` Henrik Nordstrom
  2003-10-02  9:20                 ` Jan Hudec
  1 sibling, 1 reply; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-09-15  9:28 UTC (permalink / raw)
  To: Henrik Nordstrom; +Cc: Jeff Dike, User-mode Linux Kernel Development

On Mon, 15 Sep 2003, Henrik Nordstrom wrote:
> On Mon, 15 Sep 2003, Geert Uytterhoeven wrote:
> > I removed all libpthread overridings of symbols that are used by UML
> > (intersection of 'U' symbols of vmlinux and 'T' and 'W' symbols of libpthread),
> > and now UML boots. I'll try to find out which one is the bad guy...
> 
> In this case I would say UML is one of the bad guys due to it's symbols
> which overrides libc or pthreads. Any application which needs to override
> libc primitives to work is a bad guy and pthreads is technically part of
> libc when using threaded applications.

No, UML only _uses_ those symbols, libpthread redefines them in a way that
breaks UML.

> Hoever, if UML uses clone() or other libc calls (yes, clone() is a libc
> call, direcly matched by a kernel syscall) in a manner which should not
> confuse other users of the same calls then pthreads may be a bad guy as
> well, not dealing properly with the situation.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-15  9:28                 ` Geert Uytterhoeven
@ 2003-09-15 10:51                   ` Henrik Nordstrom
  2003-09-16 18:44                     ` BlaisorBlade
  0 siblings, 1 reply; 32+ messages in thread
From: Henrik Nordstrom @ 2003-09-15 10:51 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Jeff Dike, User-mode Linux Kernel Development

mån 2003-09-15 klockan 11.28 skrev Geert Uytterhoeven:

> No, UML only _uses_ those symbols, libpthread redefines them in a way that
> breaks UML.

uml redefines several libc symbols which does conflict with pthreads.
The most notable is that uml overrides malloc/free but I think there is
also a few other overrides due to kernel library calls having the same
name as their libc equivalent calls. If you are to link with pthreads
each of these must be verified to be threads safe to the same level as
their libc/pthreads counterpart. On the positive side most kernel lib
calls most likely are threads safe due to the multithreaded nature of
the kernel, but any lib call making use of locking or other kernel
constructs will almost certainly fail or cause problems if ever invoked
from a pthread.

Regards
Henrik

-- 
Henrik Nordstrom <hno@marasystems.com>
MARA Systems AB



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-15 10:51                   ` Henrik Nordstrom
@ 2003-09-16 18:44                     ` BlaisorBlade
  0 siblings, 0 replies; 32+ messages in thread
From: BlaisorBlade @ 2003-09-16 18:44 UTC (permalink / raw)
  To: user-mode-linux-devel

Alle 12:51, lunedì 15 settembre 2003, Henrik Nordstrom ha scritto:
> mån 2003-09-15 klockan 11.28 skrev Geert Uytterhoeven:
> > No, UML only _uses_ those symbols, libpthread redefines them in a way
> > that breaks UML.
>
> uml redefines several libc symbols which does conflict with pthreads.

> The most notable is that uml overrides malloc/free but I think there is
> also a few other overrides due to kernel library calls having the same
> name as their libc equivalent calls. If you are to link with pthreads
> each of these must be verified to be threads safe to the same level as
> their libc/pthreads counterpart. On the positive side most kernel lib
> calls most likely are threads safe due to the multithreaded nature of
> the kernel, but any lib call making use of locking or other kernel
> constructs will almost certainly fail or cause problems if ever invoked
> from a pthread.
There is(from long time) the idea to make possible turning UML into a library.
This means that solving this issue in UML is worthwhile. I.e., let's suppose 
that the malloc's conflict. Then, Uml will use uml_malloc, which will be is 
own version, and everyone will be happy. Using a -Dmalloc=uml_malloc would 
make unnecessary changing the source. This is a quick idea(and details about 
the exact names are to be tuned), but I hope it's useful.
-- 
cat <<EOSIGN
Paolo Giarrusso, aka Blaisorblade
Linux Kernel 2.4.21/2.6.0-test on an i686; Linux registered user n. 292729
EOSIGN



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-12  9:07   ` Geert Uytterhoeven
  2003-09-12 11:08     ` Gerd Knorr
  2003-09-12 11:18     ` Henrik Nordstrom
@ 2003-10-02  9:08     ` Jan Hudec
  2003-10-02  9:24       ` Geert Uytterhoeven
  2003-10-06 13:29       ` [uml-devel] Re: pthreads? BlaisorBlade
  2 siblings, 2 replies; 32+ messages in thread
From: Jan Hudec @ 2003-10-02  9:08 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Gerd Knorr, User-mode Linux Kernel Development

On Fri, Sep 12, 2003 at 11:07:54 +0200, Geert Uytterhoeven wrote:
> BTW, it's libX11 that needs libpthread...

bulb@vagabond:~$ ldd /usr/X11R6/lib/libX11.so.6.2 
	libdl.so.2 => /lib/libdl.so.2 (0x400d5000)
	libc.so.6 => /lib/libc.so.6 (0x400d8000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

Not see libpthread anywhere around!

However, I just checked gmodule and glib and neither seems to report
libpthread either!

However, I just ran the simplest gtk-2.0 program I could find a greped
it's /proc/<pid>/maps for string pthr. NOT FOUND.

Thus it really looks like gtk-2.0 application does NOT have to use
pthreads!

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-09-15  9:19               ` Henrik Nordstrom
  2003-09-15  9:28                 ` Geert Uytterhoeven
@ 2003-10-02  9:20                 ` Jan Hudec
  1 sibling, 0 replies; 32+ messages in thread
From: Jan Hudec @ 2003-10-02  9:20 UTC (permalink / raw)
  To: Henrik Nordstrom
  Cc: Geert Uytterhoeven, Jeff Dike, User-mode Linux Kernel Development

On Mon, Sep 15, 2003 at 11:19:11 +0200, Henrik Nordstrom wrote:
> Hoever, if UML uses clone() or other libc calls (yes, clone() is a libc
> call, direcly matched by a kernel syscall) in a manner which should not
> confuse other users of the same calls then pthreads may be a bad guy as
> well, not dealing properly with the situation.

Just a side note: It's not overly direct. Libc does a LOT work before
calling the syscall -- the libc call takes a function argument, while
the syscall takes a stack pointer argument.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-10-02  9:08     ` Jan Hudec
@ 2003-10-02  9:24       ` Geert Uytterhoeven
  2003-10-02  9:31         ` Jan Hudec
  2003-10-06 13:29       ` [uml-devel] Re: pthreads? BlaisorBlade
  1 sibling, 1 reply; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-10-02  9:24 UTC (permalink / raw)
  To: Jan Hudec; +Cc: Gerd Knorr, User-mode Linux Kernel Development

On Thu, 2 Oct 2003, Jan Hudec wrote:
> On Fri, Sep 12, 2003 at 11:07:54 +0200, Geert Uytterhoeven wrote:
> > BTW, it's libX11 that needs libpthread...
> 
> bulb@vagabond:~$ ldd /usr/X11R6/lib/libX11.so.6.2 
> 	libdl.so.2 => /lib/libdl.so.2 (0x400d5000)
> 	libc.so.6 => /lib/libc.so.6 (0x400d8000)
> 	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
> 
> Not see libpthread anywhere around!
> 
> However, I just checked gmodule and glib and neither seems to report
> libpthread either!

ldd instead doesn't show it, but nm does:

| tux$ nm -g /usr/X11R6/lib/libX11.a | grep pthre
|          U pthread_equal
|          U pthread_cond_broadcast
|          U pthread_cond_destroy
|          U pthread_cond_init
|          U pthread_cond_signal
|          U pthread_cond_wait
|          U pthread_equal
|          U pthread_mutex_destroy
|          U pthread_mutex_init
|          U pthread_mutex_lock
|          U pthread_mutex_unlock
|          U pthread_self
| tux$ 

as does strings:

| tux$ strings /usr/X11R6/lib/libX11.so | grep pthr
| pthread_equal
| pthread_self
| pthread_mutex_lock
| pthread_mutex_unlock
| pthread_mutex_init
| pthread_mutex_destroy
| pthread_cond_init
| pthread_cond_destroy
| pthread_cond_wait
| pthread_cond_signal
| pthread_cond_broadcast
| tux$ 

| tux$ dpkg -l | grep xlibs
| ii  xlibs          4.1.0-16woody1 X Window System client libraries
| ii  xlibs-dev      4.1.0-16woody1 X Window System client library development f

BTW, during my investigation I found out that between glibc 2.3.1 and 2.3.2 the
mechanism to override sigaction and some syscalls in libpthread was modified.

In 2.3.1 libpthread just overrides the libc symbol (e.g. sigaction, open).
In 2.3.2 libpthread defines e.g. __pthread_sigaction, and libc uses the weak
symbol __pthread_sigaction to find out whether it has to use its internal
implementation __libc_sigaction, or call libpthread's __pthread_sigaction.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-10-02  9:24       ` Geert Uytterhoeven
@ 2003-10-02  9:31         ` Jan Hudec
       [not found]           ` <Pine.GSO.4.21.0310021146500.8567-100000@vervain.sonytel.be>
  0 siblings, 1 reply; 32+ messages in thread
From: Jan Hudec @ 2003-10-02  9:31 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Gerd Knorr, User-mode Linux Kernel Development

On Thu, Oct 02, 2003 at 11:24:11 +0200, Geert Uytterhoeven wrote:
> On Thu, 2 Oct 2003, Jan Hudec wrote:
> > On Fri, Sep 12, 2003 at 11:07:54 +0200, Geert Uytterhoeven wrote:
> > > BTW, it's libX11 that needs libpthread...
> > 
> > bulb@vagabond:~$ ldd /usr/X11R6/lib/libX11.so.6.2 
> > 	libdl.so.2 => /lib/libdl.so.2 (0x400d5000)
> > 	libc.so.6 => /lib/libc.so.6 (0x400d8000)
> > 	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
> > 
> > Not see libpthread anywhere around!
> > 
> > However, I just checked gmodule and glib and neither seems to report
> > libpthread either!
> 
> ldd instead doesn't show it, but nm does:

GEEE, so fend of the LAST argument in that mail, which said:

I *RAN* a simple Gtk2.0 application, greped it's /proc/<pid>/maps for
string "pthr" and DIDN'T FIND IT. Which means, that during execution of
that applications, libpthread WAS NOT IN MEMORY.

If you thing it does not have to be there, well, I also greped strace of
the application for the same string an it was not there. And all
libraries are actualy _OPEN_ during execution. So neither was it ever
READ in memory.

Still don't consider that a sufficient proof it is NOT THERE?

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
       [not found]           ` <Pine.GSO.4.21.0310021146500.8567-100000@vervain.sonytel.be>
@ 2003-10-02 13:52             ` Jan Hudec
  2003-10-02 14:28               ` Geert Uytterhoeven
  0 siblings, 1 reply; 32+ messages in thread
From: Jan Hudec @ 2003-10-02 13:52 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Gerd Knorr, User-mode Linux Kernel Development

On Thu, Oct 02, 2003 at 12:03:10 +0200, Geert Uytterhoeven wrote:
> Hence _your_ simple application doesn't need libpthread.

Hence NEITHER OF GTK, GDK, GLIB, GMODULE, GOBJECT, PANGO, ATK, X11 NEED
libpthread!

> | gcc -Wl,-T,arch/um/uml.lds.s -static -Wl,--wrap,malloc -Wl,--wrap,free -Wl, --wrap,calloc  -o linux arch/um/main.o vmlinux -L/usr/lib -lutil -L/usr/X11R6/li b -lgtk -lgdk -lX11 -lXi -lXext -lglib -lgmodule -ldl -lm -lgthread

However if you link with gthread, you need pthread.
So: a) Please don't blame it on X11.
    b) Don't link against gthread unless you need them.
    b.1) If you only call Gtk stuff in one thread, you don't need them.
    b.2) If you call Gtk stuff from more than one thread, you can still
	 provide gthread library with custom locking and get rid of
	 pthread.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-10-02 13:52             ` Jan Hudec
@ 2003-10-02 14:28               ` Geert Uytterhoeven
  2003-10-02 14:42                 ` Jan Hudec
  0 siblings, 1 reply; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-10-02 14:28 UTC (permalink / raw)
  To: Jan Hudec; +Cc: Gerd Knorr, User-mode Linux Kernel Development

On Thu, 2 Oct 2003, Jan Hudec wrote:

> On Thu, Oct 02, 2003 at 12:03:10 +0200, Geert Uytterhoeven wrote:
> > Hence _your_ simple application doesn't need libpthread.
> 
> Hence NEITHER OF GTK, GDK, GLIB, GMODULE, GOBJECT, PANGO, ATK, X11 NEED
> libpthread!
> 
> > | gcc -Wl,-T,arch/um/uml.lds.s -static -Wl,--wrap,malloc -Wl,--wrap,free -Wl, --wrap,calloc  -o linux arch/um/main.o vmlinux -L/usr/lib -lutil -L/usr/X11R6/li b -lgtk -lgdk -lX11 -lXi -lXext -lglib -lgmodule -ldl -lm -lgthread
> 
> However if you link with gthread, you need pthread.
> So: a) Please don't blame it on X11.

What about this:

| /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0x74c): In function `_XEventsQueued':
| : undefined reference to `pthread_equal'
| /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0x766): In function `_XEventsQueued':
| : undefined reference to `pthread_equal'
| /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0x781): In function `_XEventsQueued':
| : undefined reference to `pthread_equal'
| /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0x79a): In function `_XEventsQueued':
| : undefined reference to `pthread_equal'
| /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0x7b7): In function `_XEventsQueued':
| : undefined reference to `pthread_equal'
| /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0xafc): more undefined references to `pthread_equal' follow

Some investigation shows that libX11 needs pthread_equal() when linked
statically, while it doesn't need it when linked dynamically.

>     b) Don't link against gthread unless you need them.
>     b.1) If you only call Gtk stuff in one thread, you don't need them.
>     b.2) If you call Gtk stuff from more than one thread, you can still
> 	 provide gthread library with custom locking and get rid of
> 	 pthread.

I tried that, providing my own implementation for pthread_equal().
However, it hangs during gtk_init(). Since this doesn't happen within my
stand-alone GTK test app, it must be some interaction between UML and GTK...

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-10-02 14:28               ` Geert Uytterhoeven
@ 2003-10-02 14:42                 ` Jan Hudec
  2003-10-07 15:51                   ` The Story Continues (was: Re: [uml-devel] Re: pthreads?) Geert Uytterhoeven
  0 siblings, 1 reply; 32+ messages in thread
From: Jan Hudec @ 2003-10-02 14:42 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Gerd Knorr, User-mode Linux Kernel Development

On Thu, Oct 02, 2003 at 16:28:45 +0200, Geert Uytterhoeven wrote:
> On Thu, 2 Oct 2003, Jan Hudec wrote:
> 
> > On Thu, Oct 02, 2003 at 12:03:10 +0200, Geert Uytterhoeven wrote:
> > > Hence _your_ simple application doesn't need libpthread.
> > 
> > Hence NEITHER OF GTK, GDK, GLIB, GMODULE, GOBJECT, PANGO, ATK, X11 NEED
> > libpthread!
> > 
> > > | gcc -Wl,-T,arch/um/uml.lds.s -static -Wl,--wrap,malloc -Wl,--wrap,free -Wl, --wrap,calloc  -o linux arch/um/main.o vmlinux -L/usr/lib -lutil -L/usr/X11R6/li b -lgtk -lgdk -lX11 -lXi -lXext -lglib -lgmodule -ldl -lm -lgthread
> > 
> > However if you link with gthread, you need pthread.
> > So: a) Please don't blame it on X11.
> 
> What about this:
> 
> | /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0x74c): In function `_XEventsQueued':
> | : undefined reference to `pthread_equal'
> | /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0x766): In function `_XEventsQueued':
> | : undefined reference to `pthread_equal'
> | /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0x781): In function `_XEventsQueued':
> | : undefined reference to `pthread_equal'
> | /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0x79a): In function `_XEventsQueued':
> | : undefined reference to `pthread_equal'
> | /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0x7b7): In function `_XEventsQueued':
> | : undefined reference to `pthread_equal'
> | /usr/X11R6/lib/libX11.a(XlibInt.o)(.text+0xafc): more undefined references to `pthread_equal' follow
> 
> Some investigation shows that libX11 needs pthread_equal() when linked
> statically, while it doesn't need it when linked dynamically.

Ugh. That sounds strange, that a library needs something only if linked
staticaly. However, it really looks like static libX11 causing trouble.

> >     b) Don't link against gthread unless you need them.
> >     b.1) If you only call Gtk stuff in one thread, you don't need them.
> >     b.2) If you call Gtk stuff from more than one thread, you can still
> > 	 provide gthread library with custom locking and get rid of
> > 	 pthread.
> 
> I tried that, providing my own implementation for pthread_equal().
> However, it hangs during gtk_init(). Since this doesn't happen within my
> stand-alone GTK test app, it must be some interaction between UML and GTK...

It would be interesting to know where it actualy hangs.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] Re: pthreads?
  2003-10-02  9:08     ` Jan Hudec
  2003-10-02  9:24       ` Geert Uytterhoeven
@ 2003-10-06 13:29       ` BlaisorBlade
  1 sibling, 0 replies; 32+ messages in thread
From: BlaisorBlade @ 2003-10-06 13:29 UTC (permalink / raw)
  To: user-mode-linux-devel

Alle 11:08, giovedì 2 ottobre 2003, Jan Hudec ha scritto:
> On Fri, Sep 12, 2003 at 11:07:54 +0200, Geert Uytterhoeven wrote:
> > BTW, it's libX11 that needs libpthread...
>
> bulb@vagabond:~$ ldd /usr/X11R6/lib/libX11.so.6.2
> 	libdl.so.2 => /lib/libdl.so.2 (0x400d5000)
> 	libc.so.6 => /lib/libc.so.6 (0x400d8000)
> 	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
>
> Not see libpthread anywhere around!
Yes, but obviously since it's dinamically loaded, it mustn't be reported. 
libdl is used for this(Dinamic Loading). While I run gedit, which seems to 
run only 1 thread, and in its /proc/<pid>/maps found libpthread. While I ran 
xev(which is simple) and didn't find libpthread. Coming back to Gtk, I run nm 
-D on /usr/lib/libglib-2.0.so and it didn't find the "pthr" string, but did 
find the "thread" string(with names I think come from the gthread lib). So, 
they can use pthread, even if this library doesn't appear in ldd output. How 
they do is another problem: probably to use thread, the program will have to 
be linked to libgthread/pthread.
>
> However, I just checked gmodule and glib and neither seems to report
> libpthread either!
>
> However, I just ran the simplest gtk-2.0 program I could find
Which is this one? It seems like gedit it's too complex....
> and greped
> it's /proc/<pid>/maps for string pthr. NOT FOUND.
>
> Thus it really looks like gtk-2.0 application does NOT have to use
> pthreads!

-- 
cat <<EOSIGN
Paolo Giarrusso, aka Blaisorblade
Linux Kernel 2.4.21/2.6.0-test on an i686; Linux registered user n. 292729
EOSIGN



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* The Story Continues (was: Re: [uml-devel] Re: pthreads?)
  2003-10-02 14:42                 ` Jan Hudec
@ 2003-10-07 15:51                   ` Geert Uytterhoeven
  2003-10-11  1:48                     ` Jeff Dike
  2003-10-12  9:53                     ` Geert Uytterhoeven
  0 siblings, 2 replies; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-10-07 15:51 UTC (permalink / raw)
  To: User-mode Linux Kernel Development


Since TT implies static linking, I started using SKAS mode only. I applied the
SKAS patch to my host kernel (2.4.21).

Now my UML (2.6.0-test5-1) boots until initialization of my GTK/GDK frame
buffer device. During initialization, it opens a GTK window for a fraction of a
second, and crashes with

    Kernel panic: Segfault with no mm

when GTK calls my expose handler and I call gdk_draw_indexed_image() to update
the window contents.

If I run the image under gdb, it crashes even earlier in gtk_init() with

    Kernel panic: Kernel mode signal 5

If I set a breakpoint at e.g. fbmem_init() and try to run, gdb crashes with

    Kernel panic: Kernel mode signal 5

when it reaches the breakpoint.

If I try to set a breakpoint at gdkfb_init() (the initialization routine of my
frame buffer device), gdb crashes immediately with a segmentation fault.

I can set a breakpoint at e.g. setup_arch(). However, when continuing by
stepping over subroutines gdb crashes in setup_hostinfo() with a segmentation
fault.

Anyone with a clue how to investigate such behavior? Thx!

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: The Story Continues (was: Re: [uml-devel] Re: pthreads?)
  2003-10-07 15:51                   ` The Story Continues (was: Re: [uml-devel] Re: pthreads?) Geert Uytterhoeven
@ 2003-10-11  1:48                     ` Jeff Dike
  2003-10-11  8:39                       ` Geert Uytterhoeven
  2003-10-12  9:53                     ` Geert Uytterhoeven
  1 sibling, 1 reply; 32+ messages in thread
From: Jeff Dike @ 2003-10-11  1:48 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: User-mode Linux Kernel Development

geert@linux-m68k.org said:
>     Kernel panic: Segfault with no mm
> when GTK calls my expose handler and I call gdk_draw_indexed_image()
> to update the window contents.
>
> If I run the image under gdb, it crashes even earlier in gtk_init()
> with
>
>     Kernel panic: Kernel mode signal 5 

The mere act of running it under gdb causes this, or did you set some 
breakpoints?

As an arch maintainer, I bet you're aware of this, but somehow, UML is getting
a SIGTRAP that gdb isn't expecting.  Setting breakpoints in tricky ways can
do this.

> Anyone with a clue how to investigate such behavior? Thx! 

You might stick an infinite loop after the panic string is printed.  Then
attach gdb to UML then.  At least you'll get a stack trace from the panic.

				Jeff



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: The Story Continues (was: Re: [uml-devel] Re: pthreads?)
  2003-10-11  1:48                     ` Jeff Dike
@ 2003-10-11  8:39                       ` Geert Uytterhoeven
  0 siblings, 0 replies; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-10-11  8:39 UTC (permalink / raw)
  To: Jeff Dike; +Cc: User-mode Linux Kernel Development

On Fri, 10 Oct 2003, Jeff Dike wrote:
> geert@linux-m68k.org said:
> >     Kernel panic: Segfault with no mm
> > when GTK calls my expose handler and I call gdk_draw_indexed_image()
> > to update the window contents.
> >
> > If I run the image under gdb, it crashes even earlier in gtk_init()
> > with
> >
> >     Kernel panic: Kernel mode signal 5 
> 
> The mere act of running it under gdb causes this, or did you set some 
> breakpoints?

No breakpoint, just plain session under gdb.

> As an arch maintainer, I bet you're aware of this, but somehow, UML is getting
> a SIGTRAP that gdb isn't expecting.  Setting breakpoints in tricky ways can
> do this.
> 
> > Anyone with a clue how to investigate such behavior? Thx! 
> 
> You might stick an infinite loop after the panic string is printed.  Then
> attach gdb to UML then.  At least you'll get a stack trace from the panic.

Thanks! I'll try that.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: The Story Continues (was: Re: [uml-devel] Re: pthreads?)
  2003-10-07 15:51                   ` The Story Continues (was: Re: [uml-devel] Re: pthreads?) Geert Uytterhoeven
  2003-10-11  1:48                     ` Jeff Dike
@ 2003-10-12  9:53                     ` Geert Uytterhoeven
  1 sibling, 0 replies; 32+ messages in thread
From: Geert Uytterhoeven @ 2003-10-12  9:53 UTC (permalink / raw)
  To: User-mode Linux Kernel Development

On Tue, 7 Oct 2003, Geert Uytterhoeven wrote:
> Since TT implies static linking, I started using SKAS mode only. I applied the
> SKAS patch to my host kernel (2.4.21).
> 
> Now my UML (2.6.0-test5-1) boots until initialization of my GTK/GDK frame
> buffer device. During initialization, it opens a GTK window for a fraction of a
> second, and crashes with
> 
>     Kernel panic: Segfault with no mm
> 
> when GTK calls my expose handler and I call gdk_draw_indexed_image() to update
> the window contents.

Doh, turns out this was a NULL pointer dereference in my code...

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

end of thread, other threads:[~2003-10-12  9:53 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-11 15:54 [uml-devel] pthreads? Geert Uytterhoeven
2003-09-11 17:55 ` Jeff Dike
2003-09-12  8:52 ` [uml-devel] pthreads? Gerd Knorr
2003-09-12  9:07   ` Geert Uytterhoeven
2003-09-12 11:08     ` Gerd Knorr
2003-09-12 11:18       ` Geert Uytterhoeven
2003-09-12 12:15         ` Gerd Knorr
2003-09-12 12:17           ` Geert Uytterhoeven
2003-09-12 11:18     ` Henrik Nordstrom
2003-09-12 16:28       ` Jeff Dike
2003-09-12 22:25         ` Henrik Nordstrom
2003-09-13 18:53           ` Jeff Dike
2003-09-13 21:01             ` Henrik Nordstrom
2003-09-13 15:24         ` Geert Uytterhoeven
2003-09-13 18:54           ` Jeff Dike
2003-09-15  6:57             ` Geert Uytterhoeven
2003-09-15  9:19               ` Henrik Nordstrom
2003-09-15  9:28                 ` Geert Uytterhoeven
2003-09-15 10:51                   ` Henrik Nordstrom
2003-09-16 18:44                     ` BlaisorBlade
2003-10-02  9:20                 ` Jan Hudec
2003-10-02  9:08     ` Jan Hudec
2003-10-02  9:24       ` Geert Uytterhoeven
2003-10-02  9:31         ` Jan Hudec
     [not found]           ` <Pine.GSO.4.21.0310021146500.8567-100000@vervain.sonytel.be>
2003-10-02 13:52             ` Jan Hudec
2003-10-02 14:28               ` Geert Uytterhoeven
2003-10-02 14:42                 ` Jan Hudec
2003-10-07 15:51                   ` The Story Continues (was: Re: [uml-devel] Re: pthreads?) Geert Uytterhoeven
2003-10-11  1:48                     ` Jeff Dike
2003-10-11  8:39                       ` Geert Uytterhoeven
2003-10-12  9:53                     ` Geert Uytterhoeven
2003-10-06 13:29       ` [uml-devel] Re: pthreads? BlaisorBlade

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.