tensorflow / tensorflow/tensorflow
`tf.raw_ops.BlockLSTMGradV2` crashes when `seq_len_max` exceeds time dimension of inputs (missing shape validation)
Open
@dhantule is already working on this.
Since Dec 17, 2025.
awaiting PR merge
comp:ops
TF 2.19
type:bug
- Dominant language
- C++
- Stars
- 200k
- Forks
- 76.9k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 433
Description
Issue type
Bug
Have you reproduced the bug with TensorFlow Nightly?
Yes
Source
source
TensorFlow version
tf 2.19
Custom code
Yes
OS platform and distribution
No response
Mobile device
No response
Python version
No response
Bazel version
No response
GCC/compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current behavior?
When calling tf.raw_ops.BlockLSTMGradV2 with a seq_len_max value larger than the actual time dimension of inputs, the process crashes (segmentation fault) instead of raising a Python exception.
The following code would crash on tf 2.19. To reproduce the issue, I provided that a colab notebook to reproduce the error.
Standalone code to reproduce the issue
import tensorflow as tf
import numpy as np
seq_len_max = 3
batch_size = 2
input_size = 4
num_units = 5
x = tf.constant(np.random.randn(seq_len_max - 1, batch_size, input_size).astype(np.float32)) # x: (2,2,4), seq_len_max:3
cs_prev = tf.constant(np.random.randn(batch_size, num_units).astype(np.float32))
h_prev = tf.constant(np.random.randn(batch_size, num_units).astype(np.float32))
w = tf.constant(np.random.randn(input_size + num_units, 4 * num_units).astype(np.float32))
wci = tf.constant(np.random.randn(num_units).astype(np.float32))
wcf = tf.constant(np.random.randn(num_units).astype(np.float32))
wco = tf.constant(np.random.randn(num_units).astype(np.float32))
b = tf.constant(np.random.randn(4 * num_units).astype(np.float32))
i = tf.constant(np.random.randn(seq_len_max - 1, batch_size, num_units).astype(np.float32))
cs = tf.constant(np.random.randn(seq_len_max - 1, batch_size, num_units).astype(np.float32))
f = tf.constant(np.random.randn(seq_len_max - 1, batch_size, num_units).astype(np.float32))
o = tf.constant(np.random.randn(seq_len_max - 1, batch_size, num_units).astype(np.float32))
ci = tf.constant(np.random.randn(seq_len_max - 1, batch_size, num_units).astype(np.float32))
co = tf.constant(np.random.randn(seq_len_max - 1, batch_size, num_units).astype(np.float32))
h = tf.constant(np.random.randn(seq_len_max - 1, batch_size, num_units).astype(np.float32))
cs_grad = tf.constant(np.random.randn(seq_len_max - 1, batch_size, num_units).astype(np.float32))
h_grad = tf.constant(np.random.randn(seq_len_max - 1, batch_size, num_units).astype(np.float32))
use_peephole = True
result = tf.raw_ops.BlockLSTMGradV2(
seq_len_max=seq_len_max, # seq_len_max:3
x=x, # x: (2,2,4)
cs_prev=cs_prev,
h_prev=h_prev,
w=w,
wci=wci,
wcf=wcf,
wco=wco,
b=b,
i=i,
cs=cs,
f=f,
o=o,
ci=ci,
co=co,
h=h,
cs_grad=cs_grad,
h_grad=h_grad,
use_peephole=use_peephole
)
Relevant log output
2025-12-17 11:28:27.238936: F tensorflow/core/framework/tensor.cc:1078] Check failed: limit <= dim0_size (3 vs. 2)
[1] 2650852 abort (core dumped)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.