This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Some bugs in ECOS kernel


Hello, all:

I think, i found a few bugs in ECOS kernel.

1.
Please take look at folowing source code:

"packages\kernel\current\src\common\kapi.cxx"
externC cyg_bool_t cyg_thread_delete( cyg_handle_t thread )
{
    Cyg_Thread *th = (Cyg_Thread *)thread;
    if( th->get_state() != Cyg_Thread::EXITED )
        th->kill(); // encourage it to terminate
    if( th->get_state() != Cyg_Thread::EXITED )
        return false; // it didn't run yet, leave it up to the app to fix
    th->~Cyg_Thread();
    return true;
}

At first in ECOS Docs, this function described as returning void.
And second is it:
when we trying to delete not EXITED thread, 90% that th->kill() will not switch thread to EXITED state 
immediately (whereas if thread in SLEEPING state, kill() only wake up thread  and exit ), and thread will not deleted.
So, if we wrote code in accordance with ECOS docs, we'll have a troubles if after deleting thread, we freeing thread resources.

2.
see "packages\kernel\current\src\common\thread.cxx"
Function Cyg_Thread::kill(), didn't check a state of thread before check "sleep_reason". So if thread is running but "sleep_reason" not NONE (whereas after last sleeping sleep_reason not resetting to NONE), kill() will not really kill a running thread. This is a big problem if we want to delete thread in function of thread destructor ( via new thread created in destructor). See also bug 1.

3. 
see "packages\kernel\current\src\common\thread.cxx"

Cyg_Thread::kill().

Try to kill thread that in RUNNING state, will not invoke thread destructors whereas destructors calling in Cyg_Thread::exit(), but kill() invoke exit() only if thread was in SLEEPING state ( via "wake_reason=EXIT")


Please fix me if I wrong. And fix ECOS otherwise.

With best regards, Anton Kondratenko.

Russia,
Moscow,
"Tecon Ltd".




--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]