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

Some epicsThread*() leak when called from a non-EPICS thread #241

Closed
4 tasks done
mdavidsaver opened this issue May 4, 2022 · 5 comments
Closed
4 tasks done

Some epicsThread*() leak when called from a non-EPICS thread #241

mdavidsaver opened this issue May 4, 2022 · 5 comments
Assignees
Labels

Comments

@mdavidsaver
Copy link
Member

mdavidsaver commented May 4, 2022

Several of the epicsThread*() functions will allocate an epicsThreadOSD* the first time one is called from a thread not created with epicsThreadCreate*(). At present, this allocation is not free()'d automatically when the non-EPICS thread exits, causing a memory leak.

Status:

  • posix/osdThread.c - Leak observed. Fixed as of 2f8272d
  • RTEMS-score/osdThread.c - Believed to be ok
  • WIN32/osdThread.c - Candidate fix: Create implicit leak #348
  • vxWorks/osdThread.c - Believed to be ok
@mdavidsaver
Copy link
Member Author

wrt. Windows. TlsAlloc() doesn't accept a destructor function like pthread_key_create(). I found a reference to using FlsAlloc() instead, which does. This may have compatibility implications. @FreddieAkeroyd fyi.

@anjohnson
Copy link
Member

The RTEMS-score implementation has not been coded to work properly from native threads anyway. It would fault or try to access data at or just above address 0 if some APIs ever get called from a non-EPICS thread. It can't be needed by any of our existing users though since that would have been triggered before now if it was, so we should wait to resolve that issue if it ever comes up (and ask the user if they can upgrade to RTEMS-posix instead).

@anjohnson
Copy link
Member

MS blog on Windows Fibers: https://devblogs.microsoft.com/oldnewthing/20191011-00/?p=102989

@mdavidsaver
Copy link
Member Author

I merged a fix for the POSIX targets as of 2f8272d.

@mdavidsaver
Copy link
Member Author

Win32 fix f56412d in #348. All fixed in R7.0.8

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

2 participants