nasa / CFS_IO_LIB

19 stars 10 forks source link

IO_LIB's Init Calls CFE_EVS_Register() #2

Open dmccomas opened 6 years ago

dmccomas commented 6 years ago

CFE_EVS_Register() is supposed to be used within the context of an application. Calling this function during the library's initialization function will have unpredictable results.

jtovias commented 6 years ago

The IO_LibInit is treated like an application. It's included in the cfe_es_startup.src CFE_LIB, /cf/io_lib.so, IO_LibInit, IO_LIB, 0, 0, 0x0, 0;

There is no other application that's call IO_LibInit. Like all applications the IO_LibInit calls CFE_EVS_Register() to register for event services. CFE_EVS_Register() is being used correctly.

dmccomas commented 6 years ago

The cFS documentation isn’t clear on this, but libraries have a different runtime context than applications and therefore can’t use cFE services that require application context. A task is not created when a library is loaded from the cfe_es_startup.src file. When CFE_EVS_Register() is called from IO_LibInit() the first thing CFE_EVS_Register() does is get the application ID of the caller. There is no application ID for io_lib. This call should fail. Has the syslog been checked?

I wrote the trouble ticket because users have been feeding back they get a segment fault when using io_lib. This may be a situation when the system will appear to run correctly depending upon how RAM is initialized.

From: jtovias [mailto:notifications@github.com] Sent: Wednesday, May 16, 2018 7:18 PM To: nasa/CFS_IO_LIB CFS_IO_LIB@noreply.github.com Cc: Mccomas, David C. (GSFC-5800) david.c.mccomas@nasa.gov; Author author@noreply.github.com Subject: Re: [nasa/CFS_IO_LIB] IO_LIB's Init Calls CFE_EVS_Register() (#2)

The IO_LibInit is treated like an application. It's included in the cfe_es_startup.src CFE_LIB, /cf/io_lib.so, IO_LibInit, IO_LIB, 0, 0, 0x0, 0;

There is no other application that's call IO_LibInit. Like all applications the IO_LibInit calls CFE_EVS_Register() to register for event services. CFE_EVS_Register() is being used correctly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/nasa/CFS_IO_LIB/issues/2#issuecomment-389695452, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABhlCKCl-YGFiZReQv1FZelvbEUTOVI-ks5tzLOfgaJpZM4TeCyw.

jtovias commented 6 years ago

Reading more into the shared libraries. A shared library is loaded by the cfe_es_app. The cfe_es_app provides an application Id that is the assigned slot in the LibTable. https://github.com/nasa/cFE/blob/master/cfe/fsw/cfe-core/src/es/cfe_es_apps.c#L966

I'm running with CFE 6.6.0 and the cfe_es_apps.c are different. cfe 6.6.0: cfe-core/src/es/cfe_es_apps.c#L768

Below is my output for IO_LibInit. Note cfe_es_app is created with AppName CFE_EVS and appID 0. Note the appID for IOLibInit and cfe_es_app is 0 but are different. The IOLibInit appID is a LibTable entry and the cfe_es_app appID is the first appTable entry assigned in cfe_es_start:Ln834 (cfe 6.6.0)

1980-012-14:03:20.00041 ES Startup: Core App: CFE_EVS created. App ID: 0 CFE_ES_GetAppIDInternal: RecordUsed == TRUE TaskId: 0 AppId: 0 CFE_ES_GetAppIDInternal: RecordUsed == TRUE TaskId: 0 AppId: 0 -----------------------------------------------------------CFE_EVS_Register: AppName: CFE_EVS -----------------------------------------------------------CFE_EVS_Register: Status: 0 AppID : 0 EVS Port1 42/2/CFE_EVS 1: cFE EVS Initialized. cFE Version 6.6.0.0 ... ... ... 1980-012-14:03:20.25286 ES Startup: Loading shared library: /cf/io_lib.so ***IO_LibInit: Status: CFE_ES_GetAppIDInternal: RecordUsed == TRUE TaskId: 0 AppId: 0 -----------------------------------------------------------CFE_EVS_Register: AppName: CFE_EVS -----------------------------------------------------------CFE_EVS_Register: Status: 0 AppID : 0 1980-012-14:03:20.25362 IO Lib Initialized. Version 1.0.0.0

IoLibInit() calling CFE_EVS_Register() does not failed but it re-registers cfe_es_app . Using IoLibInit with cfe 6.6.0 and cfe6.5.0 have the same results. The CFE_EVS_Register() needs to be updated to check for type (app or lib) and register according.

the-other-james commented 5 years ago

io_lib fails to load for me with the following message:

ES Startup: Loading shared library: /cf/apps/io_lib.so
Failed to register with EVS (0xC4000001)
ES Startup: Load Shared Library Init Error = 0xc4000001

This corresponds to "The given application ID does not reflect a currently active application."

I am running pc-linux, x86_64 (ubuntu).

mogar commented 4 years ago

I'm using io_lib with cFS 6.7 on VxWorks 6.9. With the master io_lib code, I get an error because of this issue.

1980-012-14:03:20.00000 ES Startup: Loading shared library: /cf/io_lib.o
1980-012-14:03:42.25700 Failed to register with EVS (0xC4000001)
1980-012-14:03:20.00000 ES Startup: Load Shared Library Init Error = 0xc4000001

What is the intended solution to the issue? @the-other-james recommended just removing the registration. Would this cause any problems with the library?

jtovias commented 4 years ago

The "Failed to register with EVS (0xC4000001)" is a known issue and has been fixed. The JSC CFS team will update nasa/CFS_IO_LIB. Date for update is soon.

JALondonSpace commented 2 years ago

Has there been an update to CFS_IO_LIB yet?