Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tf.compat.v1.signal.rfft2d and rfft3d lacks input validation leading to crashes #55263

Closed
kanghj opened this issue Mar 17, 2022 · 2 comments · Fixed by #55274
Closed

tf.compat.v1.signal.rfft2d and rfft3d lacks input validation leading to crashes #55263

kanghj opened this issue Mar 17, 2022 · 2 comments · Fixed by #55274
Assignees
Labels
comp:ops OPs related issues TF 2.8 type:bug Bug

Comments

@kanghj
Copy link

kanghj commented Mar 17, 2022

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): N/A
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 2.8.0
  • Python version:3.7.12
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version: 11.2 (based on a colab notebook)
  • GPU model and memory: Tesla T4, 15109MiB (based on a colab notebook)

Describe the current behavior

The following code snippets lead to crashes when executed:

import numpy as np
import tensorflow as tf

a = np.empty([6, 0])
b = np.array([1, -1])
try:
  tf.compat.v1.signal.rfft2d(input_tensor=a,fft_length=b)
  # on a different machine: Check failed: size >= 0 (-9223372036854775808 vs. 0)
  # Aborted (core dumped)
except:
  pass

print('execution does not reach this line')

and

import numpy as np
import tensorflow as tf

a = np.empty([6, 1, 1])
b = np.array([1, 2, 0])

try:
  tf.compat.v1.signal.irfft3d(input_tensor=a,fft_length=b)
  # on a different machine: failed to initialize batched cufft plan with customized allocator: Failed to make cuFFT batched plan.
  # Aborted (core dumped)
except:
  pass
print('execution does not reach this line')

In either case, the inputs do not quite make sense, and tensorflow should throw.

Describe the expected behavior

Tensorflow should throw exceptions instead of crashing.

Contributing

  • Do you want to contribute a PR? (yes/no):
  • Briefly describe your candidate solution(if contributing):

Standalone code to reproduce the issue

Here is a colab notebook:
https://colab.research.google.com/drive/168jYG6MqnW4jpJdIXFMUBkyiaweA43aP?usp=sharing
Edit: the notebook has to be run with GPU

The code snippets above should also reproduce the issue.

@yongtang
Copy link
Member

Added PR #55274 for the fix.

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:ops OPs related issues TF 2.8 type:bug Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants