_impure_ptr invalid after task_delete() called?
Fernando RUIZ CASAS (E-mail)
fernando.ruiz at ctv.es
Wed May 29 08:21:43 UTC 2002
In tasks.c in the RTEMS core
has a small bug.
Adding a * is the solution.
Already corrected in the snapshots.
My rtems_shell had it.
Old 4.5.0
--------------------------------
---- Your version --------------
--------------------------------
User_extensions_routine _RTEMS_tasks_Delete_extension(
Thread_Control *executing,
Thread_Control *deleted
)
{
rtems_task_variable_t *tvp, *next;
/*
* Free per task variable memory
*/
tvp = deleted->task_variables;
deleted->task_variables = NULL;
while (tvp) {
next = tvp->next;
if (tvp->dtor)
(*tvp->dtor)( tvp->ptr );
if (executing == deleted)
*tvp->ptr = tvp->gval;
_Workspace_Free( tvp );
tvp = next;
}
New - corrected in the SNAPSHOTS.
rtems-ss-20020118\c\src\exec\rtems\src\tasks.c
---------------------------------
User_extensions_routine _RTEMS_tasks_Delete_extension(
Thread_Control *executing,
Thread_Control *deleted
)
{
rtems_task_variable_t *tvp, *next;
/*
* Free per task variable memory
*/
tvp = deleted->task_variables;
deleted->task_variables = NULL;
while (tvp) {
next = tvp->next;
if (tvp->dtor)
(*tvp->dtor)(*tvp->ptr ); // HERE!!!!!!!
if (executing == deleted)
*tvp->ptr = tvp->gval;
_Workspace_Free( tvp );
tvp = next;
}
BRGDS.
Fernando RUIZ CASAS
home:correo at fenando-ruiz.com
work:fernando.ruiz at ctv.es
-----Mensaje original-----
De: Phil Torre [mailto:ptorre at zetron.com]
Enviado el: miércoles, 29 de mayo de 2002 0:37
Para: RTEMS User List
Asunto: _impure_ptr invalid after task_delete() called?
(This question refers to the now-woefully-out-of-date RTEMS 4.5.0,
with an MPC860 target.)
We had some application code that was using per-task variables,
and registering a destructor function for them. Among other things,
the destructor was calling newlib functions to close files and
serial ports. Hunting down a crash bug, I discovered that the
newlib reentrancy pointer (_impure_ptr) is NULL whenever _r newlib
functions are called from the destructor.
Is it unsafe to call reentrant newlib functions from a user extension
invoked by rtems_task_delete(RTEMS_SELF)?
Many thanks,
-Phil
--
=====================================================================
Phil Torre phone: 425-820-6363 x234
Design Engineer email: ptorre at zetron.com
Switching Systems Group fax: 425-820-7031
Zetron, Inc. web: http://www.zetron.com
More information about the users
mailing list