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

Seg Fault when invalid destination filename is invalid #392

Closed
2 tasks done
the-other-james opened this issue Jun 27, 2023 · 2 comments · Fixed by #412
Closed
2 tasks done

Seg Fault when invalid destination filename is invalid #392

the-other-james opened this issue Jun 27, 2023 · 2 comments · Fixed by #412
Assignees
Milestone

Comments

@the-other-james
Copy link
Contributor

Checklist (Please check before submitting)

  • I reviewed the Contributing Guide.
  • I performed a cursory search to see if the bug report is relevant, not redundant, nor in conflict with other tickets.

Describe the bug

CF will seg-fault when uploading a file with an invalid destination filename. CF outputs an EVS message that it failed to create the file. It then appears to access a null pointer for a transaction.

Backtrace:

EVS Port1 66/1/CF 40: CF: md received for source: aa_put_file_test.txt, dest: cf/cf_test.txt
EVS Port1 66/1/CF 80: CF R0(21:3): failed to create file cf/cf_test.txt for writing, error=-108

Thread 16 "CF" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7acb700 (LWP 16577)]
CF_CFDP_SendEotPkt (t=0x7ffff7ae9c50 <CF_AppData+1328>) at /sc3m_cfs/cfs_fsw/baseline_apps/cf/fsw/src/cf_cfdp.c:1698
1698            PktBuf->eot.direction  = t->history->dir;
(gdb) bt
#0  CF_CFDP_SendEotPkt (t=0x7ffff7ae9c50 <CF_AppData+1328>) at /sc3m_cfs/cfs_fsw/baseline_apps/cf/fsw/src/cf_cfdp.c:1698
#1  0x00007ffff7ad73f2 in CF_CFDP_ResetTransaction (t=0x7ffff7ae9c50 <CF_AppData+1328>, keep_history=0)
    at /sc3m_cfs/cfs_fsw/baseline_apps/cf/fsw/src/cf_cfdp.c:1607
#2  0x00007ffff7ad5d5e in CF_CFDP_RecvIdle (t=0x7ffff7ae9c50 <CF_AppData+1328>, ph=0x7ffff7ae9a28 <CF_AppData+776>)
    at /sc3m_cfs/cfs_fsw/baseline_apps/cf/fsw/src/cf_cfdp.c:942
#3  0x00007ffff7adc052 in CF_CFDP_RxStateDispatch (t=0x7ffff7ae9c50 <CF_AppData+1328>, ph=0x7ffff7ae9a28 <CF_AppData+776>,
    dispatch=0x7ffff7ae8760 <state_fns>) at /sc3m_cfs/cfs_fsw/baseline_apps/cf/fsw/src/cf_cfdp_dispatch.c:197
#4  0x00007ffff7ad48af in CF_CFDP_DispatchRecv (t=0x7ffff7ae9c50 <CF_AppData+1328>, ph=0x7ffff7ae9a28 <CF_AppData+776>)
    at /sc3m_cfs/cfs_fsw/baseline_apps/cf/fsw/src/cf_cfdp.c:178
#5  0x00007ffff7adbb3c in CF_CFDP_ReceiveMessage (c=0x7ffff7af5ee0 <CF_AppData+51136>)
    at /sc3m_cfs/cfs_fsw/baseline_apps/cf/fsw/src/cf_cfdp_sbintf.c:295
#6  0x00007ffff7ad7335 in CF_CFDP_CycleEngine () at /sc3m_cfs/cfs_fsw/baseline_apps/cf/fsw/src/cf_cfdp.c:1575
#7  0x00007ffff7ad3ffe in CF_WakeUp () at /sc3m_cfs/cfs_fsw/baseline_apps/cf/fsw/src/cf_app.c:278
#8  0x00007ffff7ad4084 in CF_ProcessMsg (msg=0x5555555d9e60 <CFE_SB_Global+14144>)
    at /sc3m_cfs/cfs_fsw/baseline_apps/cf/fsw/src/cf_app.c:301
#9  0x00007ffff7ad4199 in CF_AppMain () at /sc3m_cfs/cfs_fsw/baseline_apps/cf/fsw/src/cf_app.c:351
#10 0x000055555556bb04 in CFE_ES_TaskEntryPoint () at /sc3m_cfs/cfs_fsw/cfe/modules/es/fsw/src/cfe_es_apps.c:579
#11 0x0000555555596695 in OS_TaskEntryPoint (task_id=65549) at /sc3m_cfs/cfs_fsw/osal/src/os/shared/src/osapi-task.c:138
#12 0x000055555559accb in OS_PthreadTaskEntry (arg=0x1000d) at /sc3m_cfs/cfs_fsw/osal/src/os/posix/src/os-impl-tasks.c:122
#13 0x00007ffff7fa5609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#14 0x00007ffff7eba133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

We are using Cosmos 4.5 with the CFDP engine. We are using the SEND FILE command.

To Reproduce
Steps to reproduce the behavior:

  1. Launch cFS with the CF app running.
  2. Use Cosmos/CFDP engine to send a file, specify an invalid filename (to a directory that doesn't exist, for example)
  3. See error in cFS output

Expected behavior

CF should report that an error happened (which it currently does), but not seg-fault :)

Code snips

None.

System observed on:

  • x86_64 PC
  • OS: Ubuntu 20.04
  • Versions: cFE 7.0 rc4, OSAL v6.0.0-rc4, PSP v1.6.0-rc4 for pc-linux.

Note that we have modified cFE, OSAL, and the PSP, but mostly to run on our target system: a microblaze running petalinux (upon which we have also observed the seg-fault).

Additional context

Observed with draco-rc2 and draco-rc4

Reporter Info
James Marshall, NASA GSFC 587

@kylenave
Copy link

kylenave commented Aug 5, 2023

I found the solution to this problem.

In cf_cfdp_r.c near line 600 (I have some changes at the moment):

    t->fd = OS_OBJECT_ID_UNDEFINED; /* just in case */
    if (t->state == CF_TxnState_R2)
    {
        CF_CFDP_R2_SetFinTxnStatus(t, CF_TxnStatus_FILESTORE_REJECTION);
    }
    else
    {
    /// I THINK THIS IS A BUG BECAUSE IT GETS RESET AGAIN AT THE END OF THIS PROCESS AND TRIES TO ACCESS "history" IN THE INTERIM.
   /// The solution is to remove this ... solves the problem for me but I haven't thoroughly explored yet.
        //CF_CFDP_R1_Reset(t);  
    }

@chillfig chillfig added the bug label Sep 1, 2023
@dmknutsen
Copy link
Contributor

@the-other-james @kylenave I was able to repeat this error and am investigating further now. Great catch and thanks for passing this along!!

@dmknutsen dmknutsen self-assigned this Oct 13, 2023
@dmknutsen dmknutsen added this to the Equuleus milestone Oct 13, 2023
dmknutsen added a commit to dmknutsen/CF that referenced this issue Oct 17, 2023
dmknutsen added a commit to dmknutsen/CF that referenced this issue Oct 17, 2023
dzbaker added a commit that referenced this issue Oct 19, 2023
Fix #392, seg fault - invalid file destination
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants