microsoft / microsoft/mimalloc

Thread local storage and QNX

Open
#309 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
13.4k
Forks
1.2k
Avg merge
4d 45m
Merged PRs (30d)
13

Description

I am working on porting mimalloc to the QNX RTOS (7.x). After some trivial changes, I have encountered an issue related to thread local storage (TLS) on QNX, that I believe is described here: https://github.com/microsoft/mimalloc/blob/master/include/mimalloc-internal.h#L280 Basically, the TLS layer calls malloc, causing my program to fall into a recursive infinite loop.

mimalloc has workarounds for MacOSX and OpenBSD. I was wondering if you could tell me more about what is being done here, so that I might develop my own workaround for QNX.

Reading the OpenBSD workaround, it seems that mimalloc is re-purposing (hijacking) an address within the pthread struct to store a pointer to the thread-local heap. Am I reading this right? Do you do this because pthread_setspecific()/pthread_getspecific() would be too slow, or are there other reasons?

Also, can you please tell me what is insufficient with the current DragonFly "workaround?"

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at include/mimalloc-internal.h#L280 and compare the MacOSX, OpenBSD, and DragonFly TLS workarounds, including the pthread_setspecific()/pthread_getspecific() paths mentioned in the report. Done would require establishing why these workarounds avoid recursive allocation and documenting or defining an appropriate QNX 7.x approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.