Skip to content

Fixes for integration tests of sem_syscalls #268

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

Merged
merged 1 commit into from
Jun 20, 2024
Merged

Conversation

yashaswi2000
Copy link
Contributor

@yashaswi2000 yashaswi2000 commented Jun 20, 2024

Description

This is a fix for [#248] issue. where we see intermittent test failures which uses semaphores. and performs actions like

  • sem_wait
  • sem_post
  • sem_timed_wait
  • sem_try_wait

The tests effected are:

  • ut_lind_fs_sem_fork()
  • ut_lind_fs_sem_trytimed()
  • ut_lind_fs_sem_test()

Causes:

  • The first kind of issue was assertion failures when sem_getvalue_syscall is performed outside of the critical section of parent/child process. which causes nondeterministic outputs since once out of critical section the busy waiting thread/process will go into its critical section and modify the semaphore value.

  • The second type is performing sem_try_wait call to enter into critical section, and always asserting a success from the call. sem_try_wait is different from sem_wait in the sense there is no busy waiting and thus if another thread/process is in the critical section, it just returns false.

  • The third kind of issue is performing sem_destroy before the child process exits its critical section. which causes nondeterministic behaviour, leading to child's sem_post call to throw error. parent process has to wait for all the threads/process to exit before destroying semaphore and shared memory.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Test A - lind_project/tests/test_cases/test_a.c
  • Test B - lind_project/tests/test_cases/test_b.c

Checklist:

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been added to a pull request and/or merged in other modules (native-client, lind-glibc, lind-project)

assert_eq!(cage.sem_destroy_syscall(shmatret as u32), 0);
// mark the shared memory to be rmoved
let shmctlret2 = cage.shmctl_syscall(shmid, IPC_RMID, None);
assert_eq!(shmctlret2, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to do this cleanup or does the exit syscall do it? It might be useful to say either way in the comments here...

Copy link
Member

@JustinCappos JustinCappos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@rennergade rennergade merged commit be794a8 into develop Jun 20, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants