Skip to content

Segfault when reading invalid HDR data #2931

@mwestphal

Description

@mwestphal

Describe the bug
F3D added support for displaying images as texture recently, however when providing an invalid image, it can segfault

To Reproduce
Steps to reproduce the behavior:

  1. Open the file using f3d --no-config --force-reader=HDR f3d.vtp
  2. segfault/assert
terminate called after throwing an instance of 'std::length_error'
  what():  cannot create std::vector larger than max_size()

Thread 1 "f3d" received signal SIGABRT, Aborted.
0x00007ffff70a7a2c in ?? () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff70a7a2c in ?? () from /usr/lib/libc.so.6
#1  0x00007ffff704d1a0 in raise () from /usr/lib/libc.so.6
#2  0x00007ffff70345fe in abort () from /usr/lib/libc.so.6
#3  0x00007ffff7297bf6 in ?? () from /usr/lib/libstdc++.so.6
#4  0x00007ffff72b1eba in ?? () from /usr/lib/libstdc++.so.6
#5  0x00007ffff72975d9 in std::terminate() () from /usr/lib/libstdc++.so.6
#6  0x00007ffff72b2176 in __cxa_throw () from /usr/lib/libstdc++.so.6
#7  0x00007ffff729bd54 in std::__throw_length_error(char const*) () from /usr/lib/libstdc++.so.6
#8  0x00007ffff2e69951 in std::vector<unsigned char, std::allocator<unsigned char> >::_S_check_init_len (__n=18446744073709501248, __a=...) at /usr/include/c++/15.2.1/bits/stl_vector.h:2216
#9  0x00007ffff2e694ec in std::vector<unsigned char, std::allocator<unsigned char> >::vector (this=0x7fffffffb5c0, __n=18446744073709501248, __a=...) at /usr/include/c++/15.2.1/bits/stl_vector.h:587
#10 0x00007ffff2e9d687 in vtkHDRReader::ReadAllFileNoRLE (this=0x55555631ac90, stream=0x555556a4faa0, outPtr=0x7ffe74d64010, decrPtr=0, outExt=0x7fffffffb840) at /home/glow/dev/vtk/vtk1/src/IO/Image/vtkHDRReader.cxx:563
#11 0x00007ffff2e9b34e in vtkHDRReader::HDRReaderUpdateSlice (this=0x55555631ac90, outPtr=0x7ffe74d64010, outExt=0x7fffffffb840) at /home/glow/dev/vtk/vtk1/src/IO/Image/vtkHDRReader.cxx:264
#12 0x00007ffff2e9ac50 in vtkHDRReader::HDRReaderUpdate (this=0x55555631ac90, data=0x555555e03130, outPtr=0x7ffe74d64010) at /home/glow/dev/vtk/vtk1/src/IO/Image/vtkHDRReader.cxx:179
#13 0x00007ffff2e9aad0 in vtkHDRReader::ExecuteDataWithInformation (this=0x55555631ac90, output=0x555555e03130, outInfo=0x55555631afe0) at /home/glow/dev/vtk/vtk1/src/IO/Image/vtkHDRReader.cxx:157

Expected behavior
No segfault, potentially an error.

System Information:

  • OS: Any
  • GPU and GPU driver: Any

F3D Information
Paste the content of f3d --version or f3d-console.exe --version on Windows: master

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions