[ECOS] RE: New revision of select() hangs my code
Mon Nov 25 16:28:00 GMT 2002
Okay, I tried Nick's test program and, of course, it worked fine on my setup
also. So I did some more digging and have managed to home in on the problem
a little more. I am not using POSIX threads in my app and I think this is
causing a problem for the new select() code. Here is what happens in my
1) My application spawns threads using the cyg_thread_create() function.
2) The new select() function calls the macro CYG_FILIO_SIGMASK_SET() on line
222 of select.cxx (v1.9)
3) This ends up calling cyg_pthread_sigmask_set() which tries to get a
thread pointer for the current thread via pthread_self_info(). This returns
NULL in my app.
4) cyg_pthread_sigmask_set() then goes on to de-reference the NULL pointer
in the following code:
if( oset != NULL )
*oset = self->sigmask;
It on the "*oset = self->sigmask;" line that my program "dies". I have to
admit that I'm not sure exactly what happens at this point. My simulator
continues to run and I don't get any errors, but my thread appears to
"hang". I'm assuming that dereferencing the NULL pointer caused some
problem in the simulator, but it's not clear to me what happened here (did
the thread die or something?).
In any case, what should this code do when not using POSIX threads? As a
side question, is it better to use POSIX threads or eCos threads in my app?
From: Dan Jakubiec
Sent: Monday, November 25, 2002 11:13 AM
To: 'Nick Garnett'
Subject: RE: New revision of select() hangs my code
Thanks for looking into that, Nick. My configuration info is:
1) I'm using the Linux synthetic target with the new_net template. I'm
running with the synthetic I/O auxiliary under RedHat 8.0.
2) My stack is 16384 bytes and I am calling select directly out of my
3) I updated my CVS at the end of last week (which is what caused my
problem). Until I picked up the changes, the code had been working fine.
I'll run the experiments you suggested. Thanks for the help!
From: Nick Garnett [mailto:firstname.lastname@example.org]
Sent: Saturday, November 23, 2002 8:59 AM
To: Dan Jakubiec
Subject: Re: New revision of select() hangs my code
Dan Jakubiec <email@example.com> writes:
> I just grabbed the latest version of
> ecos/packages/io/fileio/current/src/select.cxx (I went from rev 1.8 to
> The changes in this file break my current code which uses the select()
> I looked through the code changes, but didn't see anything obviously
> Nick Garnett: Would you mind having a look at this to see if you can see
I cannot see anything wrong with your code. I even built it into a
test program and ran it, it seems to do the right thing -- I cannot
reproduce the problem. I've attached my test program for you to try
out. I ran it on a PC using the standard net template, and got the
Main: calling pthread_join(thread1)
Thread2: calling sleep(5)
Thread1: calling socket()
Thread1: calling bind()
Thread1: calling listen()
Thread1: calling accept()
Thread2: calling socket()
Thread2: calling connect()
Thread2: writing data to stream
Thread1: calling sleep(5)
Finished flushing data
If I set the #if in pthread_entry2() to zero, I get the same, without
the "got data" lines.
You don't say what configuration you are using, maybe there is
something in that which is upsetting things. Try the standard net
template, and check that your CVS checkout is up to date. Also check
that you are not getting stack overflows -- it may be that select() is
using a little more stack than it used to.
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
More information about the Ecos-discuss