bitshuffle icon indicating copy to clipboard operation
bitshuffle copied to clipboard

Invalid read in bshuf_h5_filter

Open satarsa opened this issue 5 months ago • 0 comments

I ran valgrind from my code and stumbled upon an invalid read in bshuf_h5_filter:

Invalid read of size 4
  at 0x4ABB8CD bshuf_h5_filter (bshuf_h5filter.c:117)
  at 0x4FBC8A9 H5Z_pipeline (H5Z.c:1429)
  at 0x4C7DC29 H5D__chunk_lock (H5Dchunk.c:4540)
  at 0x4C8052B H5D__chunk_read (H5Dchunk.c:2912)
  at 0x4CAA03A H5D__read (H5Dio.c:398)
  at 0x4FAC73B H5VL__native_dataset_read (H5VLnative_dataset.c:373)
  at 0x4F8F722 H5VL__dataset_read (H5VLcallback.c:2033)
  at 0x4F96F06 H5VL_dataset_read (H5VLcallback.c:2076)
  at 0x4C64510 H5D__read_api_common (H5D.c:990)
  at 0x4C6746A H5Dread (H5D.c:1042)
...my unrelevant stack is snipped...

The actual problem is in here (at 117): https://github.com/kiyo-masui/bitshuffle/blob/526440a16baff44bd405e0741ebd285858a5408d/src/bshuf_h5filter.c#L110-L118 You don't check that cd_nelmts >= 6 and just read from cd_values[5], but in my case (no idea why) cd_nelmts == 5 and comp_lvl gets unpredictable garbage beyond actual cd_values which then goes into here (at 207): https://github.com/kiyo-masui/bitshuffle/blob/526440a16baff44bd405e0741ebd285858a5408d/src/bshuf_h5filter.c#L204-L209

satarsa avatar Nov 27 '25 16:11 satarsa