Hey, this appears to be a SEGV_ACCERR, so the page with the address is not loaded at all.
Here are the aspects of pthread_key_create to consider here:
1. parameter, 'pthread_key_t* key' may be at the wrong address.
2. parameter, key_destructor. Since this pointer is not read in this function, it's likely not the cause of the issue here.
3. global variable key_map is read. Since this is used in an application, it will be initialized much earlier, and much Android code calls this function, so since it fails here (and not in other calls to this function), I don't think there would be an issue here. Though, in the case of memory corruption, it is possible.
4. there could be a logic error in pthread_key_create which computes the bad address. However, since the function is used frequently, including on 16 KB devices, I don't think we have to worry about this case.
Here's what I'd suggest:
- For (1) more, could you print the address of the function?
- Can you share the text of the stack trace (or ideally symbolized with line numbers) so we can see where in this function it's crashing? (e.g. if it's crashing on "*key = i | KEY_VALID_FLAG;", the issue is assuredly at (1) and we need to investigate the client code)
- We also might want to run with HWASAN to discount some of these other cases.
- If you are not familiar with AllocTlsIndex, or the issue is specific to Delphi, we may want to open a chat directly with them.
- If you have a minimal repro, can you share it?