multithreaded EH is still broken on Linux/Alpha and other platforms

H.J. Lu hjl@lucon.org
Sun Sep 13 19:27:00 GMT 1998


> 
> >>>>> H J Lu <hjl@lucon.org> writes:
> 
>  >>  > The bug is in /omniORB-980827. Here is the patch. I don't know why
>  >>  > static omni_thread::init_t omni_thread_init;
>  >>  > is in the header file.
>  >> 
>  >> So that anything that #includes the header is guaranteed that the
>  >> thread stuff will have been initialized.  This is a common C++ idiom; it's
>  >> even used by many iostream implementaitons.
> 
>  > Well, it depends on what omni_thread_init does. I don't think that
>  > particular omni_thread_init is designed for having more than one
>  > copies or in any random files.
> 
> It sure looks to me like that's what it's designed for.  That line is the
> canonical form for the idiom I'm talking about.

Maybe I should have said "omni_thread_init is designed for having more
than one copies or in any random files with all C++ compilers,
especially egcs/gcc."

> 
>  >>  > It seems ok for compiler to generate
>  >>  > static omni_thread::init_t omni_thread_init;
>  >>  > for each source file which includes that header file.
>  >> 
>  >> I don't understand you.  Your patch just moves the line from the header
>  >> into the .cc files, which is unmaintainable.  Why is it useful?
> 
>  > Well, that particular .cc file I moved omni_thread_init into will
>  > be linked in by every program which uses omni_thread.
> 
>  > If you take a closer look at the files I moved omni_thread_init into,
>  > and try it on both Linux/x86 and Linux/alpha, you may understand it.
> 
> Oh, I see; you just moved it into the various thread port files.  That
> makes more sense, but subverts the intent of the original code; it relies
> on extra-linguistic means of assuring that the thread package gets
> initialized first.
> 

Well, it looks like thread initialization depends on the order and
location when compiled with egcs and glibc.

>  > Strangely enough, egcs 1.1 only generates one copy of omni_thread_init
>  > on Linux/x86 and it happens to be for that particular .cc file where I
>  > moved omni_thread_init into. However, on Linux/alpha, omni_thread_init
>  > is generated for every .cc file where the header file defining
>  > omni_thread_init is included. That is one reason why it works on x86.
>  > I think it may be an egcs bug. But I don't have the time to dig into.
> 
> That's OK, but please don't call it a fix when it is in fact a workaround.
> 

It is a bad code in my book. I won't write code like that myself.


-- 
H.J. Lu (hjl@gnu.org)



More information about the Gcc-bugs mailing list