Skip to content

[GNU/Linux][Bug Report / Question] Unable to use mimalloc after (excluding) Flutter 3.41.9 #188877

Open

Description

@alexmercerind

Steps to reproduce

Run the attached code sample on a GNU/Linux machine.

Expected results

The application launches without any issues.

Actual results

The application crashes with following logging as soon as it hits the HTTP request:

../../../flutter/third_party/libcxx/src/new.cpp:63: assertion !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new)) failed: libc++ was configured with exceptions disabled and `operator new(size_t)` has been overridden, but `operator new(size_t, nothrow_t)` has not been overridden. This is problematic because `operator new(size_t, nothrow_t)` must call `operator new(size_t)`, which will terminate in case it fails to allocate, making it impossible for `operator new(size_t, nothrow_t)` to fulfill its contract (since it should return nullptr upon failure). Please make sure you override `operator new(size_t, nothrow_t)` as well.

Code sample

https://github.com/alexmercerind/flutter-3.44.x-mimalloc-crash

Additional details

The media_kit package suffers from some severe memory leaks on GNU/Linux (I assume some memory allocation conflict/combination between Flutter, GTK/glibc, mpv etc.). Almost 3-4 years later, the cause is still unknown.

However, we discovered that shipping the app with mimalloc (an alternative memory allocator) surprisingly fixes all of the memory leaks entirely.

The code sample provided above provides a simple app which statically links the app executable to mimalloc, which now results in a crash. You may comment/uncomment this line to disable/enable mimalloc. There is no crash till Flutter version 3.41.9. The first Flutter version which crashes is Flutter 3.44.0.

One another way to use mimalloc is LD_PRELOAD. Previously, this method also fixed the memory leaks. But now, the memory usage keeps growing (though the app does not crash unlike static linking), even after loading mimalloc with LD_PRELOAD.

MIMALLOC_VERBOSE=1 LD_PRELOAD=$(ldconfig -p | awk '/libmimalloc\.so/ {print $NF; exit}') ./build/linux/x64/debug/bundle/test

I am now stuck in a situation where I can no longer upgrade my Flutter version.

Thanks a lot for your attention here.

Screenshots or Video

N/A

Logs

Logs
Launching lib/main.dart on Linux in debug mode...
Building Linux application...                                           
✓ Built build/linux/x64/debug/bundle/test
Gdk-Message: 00:00:58.244: Unable to load  from the cursor theme
Syncing files to device Linux...                                   121ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

A Dart VM Service on Linux is available at: http://127.0.0.1:37395/sWJN0iwjL-8=/
The Flutter DevTools debugger and profiler on Linux is available at: http://127.0.0.1:37395/sWJN0iwjL-8=/devtools/?uri=ws://127.0.0.1:37395/sWJN0iwjL-8=/ws
../../../flutter/third_party/libcxx/src/new.cpp:63: assertion !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new)) failed: libc++ was configured with exceptions disabled and `operator new(size_t)` has been overridden, but `operator new(size_t, nothrow_t)` has not been overridden. This is problematic because `operator new(size_t, nothrow_t)` must call `operator new(size_t)`, which will terminate in case it fails to allocate, making it impossible for `operator new(size_t, nothrow_t)` to fulfill its contract (since it should return nullptr upon failure). Please make sure you override `operator new(size_t, nothrow_t)` as well.
Lost connection to device.

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.44.4, on Fedora Linux 43 (Workstation Edition) 6.17.1-300.fc43.x86_64, locale en_US.UTF-8)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/to/linux-android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Connected device (2 available)
[✓] Network resources

! Doctor found issues in 1 category.

Activity

  1. added
    engine
    platform-linux
    team-linux
    on Jul 2, 2026
  2. mbcorona commented on Jul 2, 2026

    @mbcorona
    Member

    HI @alexmercerind , thanks for the report. Routing to the Linux team for further investigation.

  3. changed the title [-][GNU/Linux][Bug Report / Question] Unable to use mimalloc after Flutter 3.35.7[/-] [+][GNU/Linux][Bug Report / Question] Unable to use mimalloc after (excluding) Flutter 3.41.9[/+] on Jul 2, 2026
  4. alexmercerind commented on Jul 2, 2026

    @alexmercerind
    Author

    Hi!

    I have been manually compiling & testing the provided code sample against multiple Flutter versions of the past. It seems there is no crash till Flutter version 3.41.9. The first Flutter version which crashes is Flutter 3.44.0. So, the offending change is somewhat recent, and exists between the releases 3.41.9 to 3.44.0.

    I have updated the issue title/comment to reflect the discovery. I apologize for initial confusion.

    Thanks!

  5. added
    P3
    triaged-linux
    on Jul 8, 2026
  6. added a commit that references this issue on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3engineplatform-linuxteam-linuxtriaged-linux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions