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

PosKey in tilemap use int16_t but allows to set to this variable int(int32_t) #41296

Open
qarmin opened this issue Aug 15, 2020 · 3 comments
Open
Milestone

Comments

@qarmin
Copy link
Contributor

qarmin commented Aug 15, 2020

Godot version:
4.0.dev.custom_build. 69c8130

OS/device including version:
Ubuntu 20.04

Issue description:

scene/2d/tile_map.cpp:838:17: runtime error: implicit conversion from type 'int' of value 61913 (32-bit, signed) to type 'int16_t' (aka 'short') changed the value to -3623 (16-bit, signed)
scene/2d/tile_map.cpp:838:12: runtime error: implicit conversion from type 'int' of value 65129 (32-bit, signed) to type 'int16_t' (aka 'short') changed the value to -407 (16-bit, signed)

godot/scene/2d/tile_map.cpp

Lines 837 to 838 in e0ee38b

void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose, Vector2 p_autotile_coord) {
PosKey pk(p_x, p_y);

Steps to reproduce

  1. Compile Godot with this flags(output may be a little spammed)
scons p=x11 -j6 use_asan=yes use_ubsan=yes CCFLAGS="-fsanitize=pointer-compare,pointer-subtract,shift,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin,nullability-return,nullability-arg,function,nullability-assign,implicit-integer-sign-change,implicit-signed-integer-truncation,implicit-unsigned-integer-truncation" use_llvm=yes;sudo cp bin/godot.x11.tools.64.llvms /usr/bin/godots

Minimal reproduction project:
Probably most project with a little advanced tiles should work but this happens with
https://github.com/qarmin/The-worst-Godot-test-project/archive/master.zip

@aaronfranke
Copy link
Member

See the discussion here: #39976 (comment)

@qarmin
Copy link
Contributor Author

qarmin commented Aug 16, 2020

PosKey overflow is also visible with - https://github.com/godotengine/godot-demo-projects/tree/master/2d/hexagonal_map
which show this error when running editor

scene/2d/tile_map.cpp:1238:24: runtime error: implicit conversion from type 'int' of value -2147483648 (32-bit, signed) to type 'unsigned int' changed the value to 2147483648 (32-bit, unsigned)
scene/2d/tile_map.cpp:858:17: runtime error: implicit conversion from type 'int' of value 65529 (32-bit, signed) to type 'int16_t' (aka 'short') changed the value to -7 (16-bit, signed)
scene/2d/tile_map.cpp:1244:14: runtime error: implicit conversion from type 'uint16_t' (aka 'unsigned short') of value 47217 (16-bit, unsigned) to type 'int16_t' (aka 'short') changed the value to -18319 (16-bit, signed)
scene/2d/tile_map.cpp:904:33: runtime error: -18319 is outside the range of representable values of type 'unsigned short'
scene/2d/tile_map.cpp:904:23: runtime error: implicit conversion from type 'uint16_t' (aka 'unsigned short') of value 47217 (16-bit, unsigned) to type 'int16_t' (aka 'short') changed the value to -18319 (16-bit, signed)

There is only 26 tiles and map size is ~(20,20) so big size of tilemap isn't necessary to produce this bug

@aaronfranke
Copy link
Member

That sounds like a separate bug. I don't see why the hexagonal map demo would have tiles at positions like 65529 or -2147483648, since all of the tiles should have 1 or 2 digit positions.

@groud groud added this to the 3.4 milestone May 24, 2021
@akien-mga akien-mga modified the milestones: 3.4, 3.5 Nov 8, 2021
@KoBeWi KoBeWi modified the milestones: 3.5, 3.x Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants