Skip to content

Critical Bug: Segmentation fault in pcolormesh plot with array dimension mismatch #430

@krystophny

Description

@krystophny

Bug Description

Segmentation fault occurs when creating pcolormesh plots, caused by array dimension mismatch in pcolormesh initialization.

Steps to Reproduce

  1. Create coordinate arrays x(6), y(5) and color array c(5,4)
  2. Call pcolormesh(x, y, c)
  3. Program crashes with segmentation fault

Stack Trace

Error in initialize_regular_grid: Array dimension mismatch
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace:
#0  0x7fc98463e53f in ???
#1  0x563848aab920 in __fortplot_pcolormesh_MOD_get_data_range at ././src/fortplot_pcolormesh.f90:201
#2  0x563848a926a4 in add_pcolormesh_plot_data at ././src/fortplot_figure_core.f90:670
#3  0x563848aa4eab in __fortplot_figure_core_MOD_add_pcolormesh at ././src/fortplot_figure_core.f90:243
#4  0x563848ac1be2 in __fortplot_matplotlib_MOD_pcolormesh at ././src/fortplot_matplotlib.f90:102

Expected Behavior

Should either:

  • Create pcolormesh plot with proper array handling
  • Provide clear error message for dimension mismatch
  • Handle edge case gracefully

Actual Behavior

  • Program crashes with segmentation fault
  • No graceful error handling

Environment

  • OS: Linux
  • Fortran compiler: gfortran
  • Branch: fix-rescue-backlog-commits-272

Test Case

integer, parameter :: nx = 6, ny = 5
real(wp) :: x(nx), y(ny), c(nx-1, ny-1)
! Initialize arrays...
call pcolormesh(x, y, c, colormap='plasma')  ! Crashes

Impact

  • Critical: Complete program crash
  • Affects all pcolormesh plotting functionality
  • No workaround available
  • Data loss due to segmentation fault

Source Analysis

Issue appears to be in fortplot_pcolormesh.f90 at line 201 in get_data_range function, triggered during pcolormesh initialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions