Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS Seg Faults when using memory definition table (CS.DefMemoryTbl) #25

Closed
dmknutsen opened this issue Apr 26, 2022 · 6 comments
Closed
Assignees
Labels

Comments

@dmknutsen
Copy link
Contributor

dmknutsen commented Apr 26, 2022

Describe the bug
On a 64-bit system, CS will intermittently seg fault when it attempts to checksum an address defined by the memory definition table (CS.DefMemoryTbl). Further, when you dump the results table for a given address defined by the memory definition table - the address is byte swapped...which I do not believe to be the expected result and may help in de-bugging this issue.

To Reproduce
Steps to reproduce the behavior:

  1. Start cFS
  2. Load/validate/activate a memory definition table with a non-zero address
  3. Observe Seg fault when CS attempts to checksum the entry with non-zero starting address.

System observed on:
Oracle VM VirtualBox
OS: ubuntu-20.10
Versions: cFS Versions: cfe v7.0.0-rc4+dev96, osal v6.0.0-rc4+dev66, psp v1.6.0-rc1+dev14.

Reporter Info
Dan Knutsen
NASA Goddard

@astrogeco astrogeco added the bug label Apr 27, 2022
@astrogeco astrogeco added this to the Draco milestone Apr 27, 2022
@astrogeco
Copy link
Contributor

CCB:2022-04-27 DISCUSSED

@skliper skliper assigned skliper and semaldona and unassigned skliper Apr 28, 2022
@semaldona
Copy link

On Linux, the checksum addresses used in the memory tables must be accessible to the cFS process in userspace. CS uses the cFE API cFE_ES_CalculateChecksum, which makes the assumption that the memory addresses are directly accessible and do not require any special logic to access. See https://github.com/nasa/cFE/blob/main/modules/es/fsw/src/cfe_es_api.c#L1691. Any attempt to access memory not available to the cFS process will cause the Linux kernel to raise an exception and cause a segmentation fault.

Because the Linux process memory address range may change with each invocation of the cFS executable, a memory address that was once accessible on a previous run may not be accessible on a subsequent one. This makes it impractical to use hard coded addresses in CS memory tables on Linux without some special setup.

The byte swap issue was found to be caused by the CTF reqval plugin script not accounting for the endianness of the target platform.

Recommending closure of this issue as no CS defect was identified.

@skliper
Copy link
Contributor

skliper commented May 4, 2022

Marked for discussion (@astrogeco). One approach for systems that aren't using fixed addresses would be to create the table "on the fly". For CTF testing maybe use an app to generate the table that you could run, then load that generated table based on the currently valid addresses (all in the same run).

@astrogeco
Copy link
Contributor

CCB:2022-05-04 Discussed

  • Create table after you know what the valid addresses are
  • Use dynamic lookup to choose a valid symbol in testing
  • @dmknutsen to test manually and show that this works before closing
  • Can we protect against segfaults?
  • Should we deprecate hard-coded addresses in tables? What are the use cases? Are they frequent enough?
  • This functionality can be replicated using the "one shot" checksum command

@dmknutsen
Copy link
Contributor Author

We are looking into the possibility of creating 'tables on the fly' for CTF testing. This issue can be closed because the seg faults are the expected Linux behavior.

@skliper
Copy link
Contributor

skliper commented May 16, 2022

Just to clarify - the memory definition table memory addresses and sizes all need to be valid or a SEGFAULT could occur due to CS attempting to read invalid memory. The PSP could catch a SEGFAULT and handle it if needed.

@skliper skliper added invalid and removed bug labels May 16, 2022
@skliper skliper removed this from the Draco milestone Jul 11, 2022
skliper pushed a commit to skliper/CS that referenced this issue Sep 9, 2022
…ent_text

Fix nasa#25, RTS not loaded event no longer implies failure in text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants