Skip to content

munmap_chunk(): invalid pointer error when trying to get_mapping of controllerย #3595

@jackburridge

Description

@jackburridge

Environment:

pygame-ce 2.5.5 (SDL 2.32.6, Python 3.13.6)
Platform:		Linux-6.16.3-76061603-generic-x86_64-with-glibc2.35
System:			Linux
System Version:		#202508231538~1758561135~22.04~171c8de SMP PREEMPT_DYNAMIC Mon S
Processor:		x86_64	SSE2: Yes	AVX2: Yes	NEON: No
Architecture:		Bits: 64bit	Linkage: ELF

Python:			CPython 3.13.6 (main, Aug  6 2025, 22:57:45) [Clang 20.1.4 ]
GIL Enabled:		True
pygame version:		2.5.5
SDL versions:		Linked: 2.32.6	Compiled: 2.32.6
SDL Mixer versions:	Linked: 2.8.1	Compiled: 2.8.1
SDL Font versions:	Linked: 2.24.0	Compiled: 2.24.0
SDL Image versions:	Linked: 2.8.8	Compiled: 2.8.8
Freetype versions:	Linked: 2.13.3	Compiled: 2.13.3

Display Driver:		Display Not Initialized
Mixer Driver:		Mixer Not Initialized

Other environment details, not included in print_debug_info(), that might help:

  • Relevant hardware

Nintendo Switch Joy-Con (L)

Additional output from the test code

joystick.get_name(): Joy-Con (L)
joystick.get_guid(): 050067007e0500000620000001800000
controller.name: Nintendo Switch Joy-Con (L)

Current behavior:

There is a invalid pointer error when trying to get_mapping()

Expected behavior:

When using get_mapping() a dictionary is returned

Steps to reproduce:

  1. Connect a single controller
  2. Initialize controllers
  3. Get the mapping of the first controller

Test code

Assuming only one controller is plugged in

import pygame._sdl2.controller

if __name__ == "__main__":
    pygame.print_debug_info()

    pygame._sdl2.controller.init()
    pygame.joystick.init()
    print(pygame._sdl2.controller.get_init())

    controller = pygame._sdl2.controller.Controller(0)
    joystick = pygame.joystick.Joystick(0)

    controller.init()

    print(f"joystick.get_name(): {joystick.get_name()}")
    print(f"joystick.get_guid(): {joystick.get_guid()}")
    print(f"controller.name: {controller.name}")

    print(controller.get_mapping())

Error output

munmap_chunk(): invalid pointer

Metadata

Metadata

Assignees

No one assigned

    Labels

    _sdl2pygame._sdl2bugNot working as intendedcontrollerpygame.controller

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions