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

Buffer generated in python gets rejected by flatcc [Python / C, Flatbuffer 23.5.26] #8248

Open
MaximeLucasSky opened this issue Mar 7, 2024 · 1 comment

Comments

@MaximeLucasSky
Copy link

I am encoding a flatbuffer with python bindings, and am trying to validate it in C using XXX_verify_as_root_with_identifier, which is failing.
I believe the issue occures because of a wrong table size generated by can be seen in the fllowing excerpt of the annotated output:

vtable (Affine, CalibData):
  +0x0A62 | 0A 00                   | uint16_t   | 0x000A (10)                       | size of this vtable
  +0x0A64 | 0C 00                   | uint16_t   | 0x000C (12)                       | size of referring table
  +0x0A66 | 0C 00                   | VOffset16  | 0x000C (12)                       | offset to field `temp_range` (id: 0)
  +0x0A68 | 08 00                   | VOffset16  | 0x0008 (8)                        | offset to field `a` (id: 1)
  +0x0A6A | 04 00                   | VOffset16  | 0x0004 (4)                        | offset to field `b` (id: 2)

table (Affine):
  +0x0A6C | 0A 00 00 00             | SOffset32  | 0x0000000A (10) Loc: 0x0A62       | offset to vtable
  +0x0A70 | AC 01 00 00             | UOffset32  | 0x000001AC (428) Loc: 0x0C1C      | offset to field `b` (vector)
  +0x0A74 | 18 00 00 00             | UOffset32  | 0x00000018 (24) Loc: 0x0A8C       | offset to field `a` (vector)
  +0x0A78 | 00 00 00 00 00 00 59 C0 | double     | 0xC059000000000000 (-100)         | struct field `temp_range.inf` of 'TempRange' (Double)
  +0x0A80 | 00 00 00 00 00 00 59 40 | double     | 0x4059000000000000 (100)          | struct field `temp_range.sup` of 'TempRange' (Double)

and here is an excerpt of the schema :

struct TempRange{
    inf:double;
    sup:double;
}

table Polynom {
    coeffs:[double];
}

table Affine{
    temp_range:TempRange;
    a:[Polynom];  
    b:[Polynom];  
}

The issue seems to be that, in the vtable, the size of the referring table is 12, which is too small to take into account the TempRange struct.
Is this indeed an encoder error ? Or is it a false positive of the verifier ?

@MaximeLucasSky MaximeLucasSky changed the title Buffer generated in python gets rejected by flatcc [Python / C, Flatbuffer 22.5.26] Buffer generated in python gets rejected by flatcc [Python / C, Flatbuffer 23.5.26] Mar 7, 2024
@mjdorma
Copy link

mjdorma commented May 8, 2024

Is it possible, in Python, that you are creating the struct temp_range:TempRange before beginning the Affine table?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants