io icon indicating copy to clipboard operation
io copied to clipboard

Segmentation fault when using decode_json on an object with null values

Open jacekwasilewski opened this issue 2 years ago • 1 comments

Hi! Calling decode_json on an object that contains a null value, results in a segmentation fault.

import tensorflow as tf
print(tf.__version__)
import tensorflow_io as tfio
print(tfio.__version__)

INPUT_SPEC = {
    "user_id": tf.TensorSpec(shape=(), dtype=tf.string),
    "actions": tf.TensorSpec(shape=(None,), dtype=tf.string),
}
tfio.experimental.serialization.decode_json(
    b'{"user_id":null,"actions":[]}\n',
    INPUT_SPEC, name=None
)
2.9.0
0.26.0
Segmentation fault (core dumped)

Same if the list contains a null:

INPUT_SPEC = {
    "user_id": tf.TensorSpec(shape=(), dtype=tf.string),
    "actions": tf.TensorSpec(shape=(None,), dtype=tf.string),
}
tfio.experimental.serialization.decode_json(
    b'{"user_id":"0000asdasdasdasdas dasdasdasdasdasd","actions":[null]}\n',
    INPUT_SPEC, name=None
)

This may be similar to #1605 .

jacekwasilewski avatar Jun 22 '22 16:06 jacekwasilewski

Tagging @yongtang as fixed the previous issue any maybe would know what to do with this one. :)

jacekwasilewski avatar Jun 22 '22 16:06 jacekwasilewski