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

A bug in SpinLockGuard::into_raw #37

Closed
efenniht opened this issue Aug 22, 2019 · 1 comment · Fixed by #39
Closed

A bug in SpinLockGuard::into_raw #37

efenniht opened this issue Aug 22, 2019 · 1 comment · Fixed by #39

Comments

@efenniht
Copy link
Collaborator

현재의 구현은 다음과 같습니다:

impl<'s, T> SpinLockGuard<'s, T> {
    pub fn into_raw(self) -> usize {
        self.lock as *const _ as usize
    }
  1. 이 함수는 unsafe 해야 합니다. 만약에 reference를 인자로 받았으면 달라지는데, 지금은 SpinLockGuard를 소모하면서 락을 안 풀기 때문입니다.
  2. 진짜 버그: 이 함수는 리턴하면서 락을 사실 풉니다! mem::forget(self) 로 명시적으로 destructor를 호출하지 않도록 고쳐야 합니다.
@efenniht
Copy link
Collaborator Author

그래서 이것은 다음 VCpu 관련 PR에서 수정하도록 하겠습니다.

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 a pull request may close this issue.

1 participant