modersohn / delphi-tree-sitter

Delphi binding for the tree-sitter library
MIT License
7 stars 2 forks source link

Crash on x86 aka Win32 when querying node end point #1

Closed modersohn closed 6 months ago

modersohn commented 6 months ago

Can be seen running the VCL Demo with Win32 being the target platform.

Crash occurs when calling ts_node_end_point(). ts_node_start_point() does not crash, but does not return the correct location.

Originally TSPoint is defined as

typedef struct TSPoint {
  uint32_t row;
  uint32_t column;
} TSPoint;

which I translated to

  TSPoint = packed record
    row: UInt32;
    column: UInt32;
  end;

This works fine on Win64 where the size of the struct equals the size of a pointer. On Win32 that's not the case.

Calling convention for both APIs is explicitly set to cdecl.

modersohn commented 6 months ago

Links to remember:

modersohn commented 6 months ago

Issue still open as the workaround (declaring the function return type as Int64) only works for ts_node_end_point. For ts_node_start_point garbage is returned, which also breaks selection of the code portion. All on Win32 only. Win64 is just fine

modersohn commented 6 months ago

Now fixed by missing cdecl.