Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

malloc returns the same pointer as a previous unfreed malloc on win64 with lg-tiny-min=4 #368

@glandium

Description

@glandium

STR:

  • Build jemalloc on win64 (only tried msvc) with --with-lg-tiny-min=4 --enable-debug
  • Build the following testcase against jemalloc:
#include <stdio.h>

extern void *je_malloc(size_t);

int main() {
  void *cur, *prev = NULL;
  for (int i = 0; ; i++) {
    void *cur = je_malloc(40);
    if (prev == cur) {
      printf("%d\n", i);
      return 1;
    }
    prev = cur;
  }
  return 0;
}

The output is:

<jemalloc>: z:\jemalloc\include\jemalloc/internal/bitmap.h:173: Failed assertion
: "!bitmap_get(bitmap, binfo, bit)"

The output without --enable-debug is 33.

Git bisect points at b8823ab as the first commit that fails, and sure enough, if I force USE_TREE, it works properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions