google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
22.52k stars 3.19k forks source link

TS: segfault/crash with --gen-object-api for array of enums #8311

Open jtbandes opened 1 month ago

jtbandes commented 1 month ago

The following schema triggers a segmentation fault:

enum Color : byte { Red = 1, Green, Blue }

struct MyStruct {
  xyz:[Color:1];
}
$ flatc --version
flatc version 24.3.25
$ flatc --ts --ts-no-import-ext --gen-object-api -o gen *.fbs
zsh: segmentation fault  flatc --ts --ts-no-import-ext --gen-object-api -o gen *.fbs

This seems to occur because 0 is not a valid value for Color. If you change Red = 1, to Red = 0, or just Red, then the crash no longer occurs.

If you remove the --gen-object-api the crash no longer occurs.