COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### What is wrong with pthread_kill on Redhat Linux ???

• Email
• Follow

Hi,
I have redhat 9.0 Linux installed on my system with gcc 3.2.3.
This is the program i used, i compiled it with -lpthread option.

Here i am starting 3 threads and then i am calling pthread_kill on a
thread which is non-existent , the signal being passed is '0'.
According to the POSIX standard if the thread doesn't exist it should
set errno to ESRCH. But instead it causes a segmentation fault.
Why is that ???
Is there any work around to this problem ???
Is this a linux problem or just Redhat 9.0 problem???

#include <stdio.h>
#include <unistd.h>
#include<signal.h>
#include <errno.h>

void* do_loop(void* data)
{
long int i;
int j;
int me = *((int*)data);

while (1) // infinite loop
{
i++;
if( i%1000000== 0)
printf("thread %d - i val %d\n", me, i);
if(i==225000000)
}
pthread_exit(NULL); // There is no point of this actually
}

int main()
{
int        thr_id;
int        a = 1;
int        b = 2;
int        c = 3;
int        d = 4;

if(pthread_create(&id, NULL, do_loop, (void*)&a) != 0)

if(pthread_create(&id, NULL, do_loop, (void*)&c) != 0)

if(pthread_create(&id, NULL, do_loop, (void*)&d) != 0)

{
}

else
{
sleep(10);
}
return 0;
}

//P.S : This very same program works on Solaris!!!

 0
Reply anoop_kn (5) 1/23/2004 11:39:18 AM

See related articles to this posting

anoop_kn@yahoo.com (Anoop Kumar) writes:

> Hi,
> I have redhat 9.0 Linux installed on my system with gcc 3.2.3.
> This is the program i used, i compiled it with -lpthread option.
>
> Here i am starting 3 threads and then i am calling pthread_kill on a
> thread which is non-existent , the signal being passed is '0'.
> According to the POSIX standard if the thread doesn't exist it should
> set errno to ESRCH. But instead it causes a segmentation fault.
> Why is that ???
> Is there any work around to this problem ???
> Is this a linux problem or just Redhat 9.0 problem???

It's a weakness in the new NPTL thread library used by redhat 9.
pthread_kill and a few other functions cast the pthread_t to a pointer
and attempt to dereference it.  Obviously, this will cause a
segmentation fault.  The only workaround I can think of is not to pass
invalid thread IDs to these functions.

--
M�ns Rullg�rd
mru@kth.se

 0

M�ns Rullg�rd wrote:
> anoop_kn@yahoo.com (Anoop Kumar) writes:
>
>
>>Hi,
>>I have redhat 9.0 Linux installed on my system with gcc 3.2.3.
>>This is the program i used, i compiled it with -lpthread option.

BTW -- compile with -pthread', not -lpthread' (though it's not
directly relevant here it will avoid other potential problems).

>>
>>Here i am starting 3 threads and then i am calling pthread_kill on a
>>thread which is non-existent , the signal being passed is '0'.
>>According to the POSIX standard if the thread doesn't exist it should
>>set errno to ESRCH. But instead it causes a segmentation fault.
>>Why is that ???
>>Is there any work around to this problem ???
>>Is this a linux problem or just Redhat 9.0 problem???
>
>
> It's a weakness in the new NPTL thread library used by redhat 9.
> pthread_kill and a few other functions cast the pthread_t to a pointer
> and attempt to dereference it.  Obviously, this will cause a
> segmentation fault.  The only workaround I can think of is not to pass
> invalid thread IDs to these functions.
>

--ag
--
Artie Gold -- Austin, Texas

 0

2 Replies
714 Views

Similar Articles

12/6/2013 1:33:44 AM
page loaded in 102795 ms. (0)

Similar Artilces:

What is wrong with this !
Could somebody please advise what is wrong with the following. I am using it in %let in place of the final day of last month. (Originally the %let was = '2005-05-31', but I was trying to change it so that I did not have to alter it each month when I ran the program.) %let DATE_end = intnx("month",date(),-1,'e'); with thanks Bob

What is wrong with my array
;}) AAdd (aMedia,{"115","Text15"}) dwLen := ALen(aMedia) // result for dwLen is 16, it is true FOR n := 1 UPTO dwLen ? aMedia [n][1], aMedia [n][2] n++ NEXT The result is: 100,Text0 102,Text2 104,Text4 106,Text6 108,Text8 ........ but it should be: 100,Text0 101,Text1 102,Text2 103,Text3 104,Text4 ...... What I did wrong? Zeljko. Il Tue, 26 Jan 2010 03:15:18 -0800, Zex ha scritto: > I made two-dimensional array. This is my code: > > LOCAL aMedia AS ARRAY...,{"115","Text15"}) > > > dwLen := ALen(aMedia) > > // result for dwLen is 16, it is true > > FOR n := 1 UPTO dwLen > ? aMedia [n][1], aMedia [n][2] > n++ > NEXT > > The result is: > 100,Text0 > 102,Text2 > 104,Text4 > 106,Text6 > 108,Text8 > ....... > but it should be: > 100,Text0 > 101,Text1 > 102,Text2 > 103,Text3 > 104,Text4 > ..... > > What I did wrong? > > Zeljko. You put n

wrong accent in matthmode
I'm trying to get in accent which has the same shape in "1." as in "2." In "2." I have the right shape, but in "1." neither \acute{} nor \grave{} give the shape I'm looking for: 1. \subsection{$\mathbf{Verb model~~\grave{}\,ic_1tac_2a - yic_1tac_2i}$} ^^^^^^ 2. \subsubsection{'i\v stara-'i\v starayt-yi\v stari [to buy]} ^ ^ any help is appreciated regards, hugo hugocoolens@gmail.com wrote: > I'm trying to get in accent which

Firefox, wrong fonts with gtk2
with gtk 1? My guess (may be totally wrong): for the gtk2 version, the font selection probably goes through fontconfig. It is likely that fontconfig is configured not to use bitmap fonts, but the only nice-looking fonts on your machine are bitmaps. Two things you could try: - look for a file named fonts.conf somewhere, you should be able to modify a local.conf next to it that allows bitmap fonts - install vectorial fonts (there are plenty of truetype fonts available for free) Additionally, for a better rendering of the vectorial fonts, you can try compiling a more recent version of freetype, and set the variable that enables the legally-questionable improvements (documented in the README). In article <g0srgj$2bc9$1@nef.ens.fr>, Marc <marc.glisse@gmail.com> wrote: >Thomas Schulz wrote: > >> Does anyone know why Firefox built with gtk 2 has a different set of >> fonts, and does anyone know how to get it to use the same fonts as when >> built with gtk 1? > >My guess (may be totally wrong): >for the gtk2 version, the font selection probably goes through >fontconfig. It is likely that fontconfig is configured not to use bitmap >

Is there anything wrong with this news group?
From what I saw,this web hasn't been updated for two days!(10/9/2004,10/10/2004) Or is anything wrong with my own system? Wang Dong wrote: > From what I saw,this web hasn't been updated for two days!(10/9/2004,10/10/2004) > Or is anything wrong with my own system? Those are Saturday and Sunday, not ususally workdays in the US. There is not much activity on those days. I did see 6 or so posts during that period. Maybe your ISP is a bit slow in updating. You can look at Google by date and see what they have. Speaking only for myself, Joe Durusau

wrong table/column dimensions
Hi I try to insert a table with a certain width, which should contain columns of different width (since the amount of text varies quite a lot and equal sized columns would cost me lots of space). However, whenever I define the dimensions of the whole table and the columns, the columns exceed the table width (although the horizontal lines are o.k.). A minimum example would be something like: \documentclass{scrartcl} \begin{document} \begin{tabular*}{165mm}{|p{25mm}|p{25mm}|p{25mm}|p{30mm}|p{30mm}| p{30mm}|}\hline Wissens\-domaene & Fahr\-auf\-gaben\-ebene & Subdomaene & Bsp. &

What is wrong with the following code ?
Hi! What is wrong with the following code ? // Test1.cpp : Defines the entry point for the console application. // #include "stdafx.h" class CTest1 { public: CTest1(){} virtual ~CTest1() = 0; }; class CTest2: public CTest1 { public: CTest2(){} virtual ~CTest2(){} }; int main(int argc, char* argv[]) { printf("Hello World!\n"); CTest2 test; return 0; } Because the desctructor for the class CTest1 is pure virtual I cannot instantiate variables of type CTest2 ?!! Since the destructor is not inherited the only option is to provide a body for the pure virtual destrcutor. (I forgot to mention that I get a linker error on VC++6.0 and VC++7.0) Is this normal behaviour ? I mean why I cannot instantiate CTest2 ? Because the destructor is not inherited the fact that the base destructor is pure virtual should be irrelevant. Regards, Razvan mihai11@mailcity.com (Razvan) wrote in news:15f19d61.0406211206.66da6ecf@posting.google.com: > Hi! > > > > What is wrong with the following code ? > > > // Test1.cpp : Defines the entry point for the console application. > // > > #include "stdafx.h" > >

FO3
Read just a few of the reviews at:- http://fallout.bethsoft.com/eng/links/fallout3-reviews.php Bethesda must have a vast world-wide reviewer-bribery war-chest... or......... better still (buy and) play the game (for a minimum of,say, 10 game-hours) and come to your own conclusions..... John Lewis John Lewis <john.dsl@verizon.net> wrote: > Read just a few of the reviews at:- > > http://fallout.bethsoft.com/eng/links/fallout3-reviews.php > > Bethesda must have a vast world-wide reviewer-bribery war-chest... > or......... better still (buy and) play the game (for a

What (WAS) wrong with my network?
Hello, Jeff your throughput increased from 9.9kB/s to 790kB/s and 90.1kB/s to 1.1MB/s. This is still fare away from the possibilities. In our network I did see a throughput within a range from 85%...95% of the line speed (e.g. 11.2MB/s for a 100Base-TX and 1.2MB/s for a 10Base-T line). Try to set the 100Base-TX ports to full duplex and test again. May be you will get a better performance. Our experience is, if you have a manageable switch, set both sides to 100Base-TX full duplex. Also it is important, that you do this also within the console mode. Also be aware, that the PIPELINE QUOTA is le

WTF is wrong with 3D Gamers?
then > I would think that would make it an easier decision. > > But as you say, we have been here before. Its still a great example of a > site doing it a different way than 3Dgamers did, but getting the same > level of angry response. They all have pick an answer eventually. I think Gamespot's answer is much closer to what works than 3DGamers. See, I think 3DGamers has gone down the wrong path. I think Gamespot has gone down a path I personally dislike. -- Elizabeth D. Brooks | kali.magdalene@comcast.net | US2002021724 Listowner: Aberrants_Worldwide, Fading_Suns_Games