(Mac) strdup crashes Simulator?

I'm trying to use strdup to capture a result of JSON parsing. After using it, I'd like to free the memory. Doing to seems to misbehave in the Simulator but not on the device...

I minimized this to a simple strdup of a constant string, and it has the same effect: works fine on-device, crashes the Simulator instantly. Could this be something wrong with my setup or is the Simulator at fault? I would've expected it to work on both platforms.

Reproduction code:

#include "pd_api.h"

int update(void *userdata)
{
  return 0;
}

int eventHandler(PlaydateAPI *pd, PDSystemEvent event, uint32_t arg)
{
  if (event == kEventInit)
  {

    char *mystring = strdup("hello");
    free(mystring);

    pd->system->setUpdateCallback(update, pd);
  }

  return 0;
}

Edit: as a workaround, a custom strdup implementation seems to work fine. I'm worried, however, that a transitive call to strdup (e.g. in a third-party library) might still be problematic.

char *mystrdup(const char *s)
{
  char *d = malloc(strlen(s) + 1);
  if (d == NULL)
    return NULL;
  strcpy(d, s);
  return d;
}

I can't reproduce the crash with these lines added to the Hello World example.

char *mystring = strdup("hello");
free(mystring);

Could you attach the crash log you're getting?

OK, reproduced this with the malloc pool enabled. If you look at setup.c you can see free() is remapped to pdrealloc(). However, strdup() is likely doing something else to allocate its memory so you'll see a mis-match allocation and then a crash. Hope this makes sense.

Wait, but isn't setup.c not included in simulator builds?

It is, but the crash only manifests if you have malloc pool enabled (for me anyway) since it's doing additional memory tracking.

Thank you for all the replies @willco. I didn't notice that the malloc pool changed things up.
The explanation makes sense.