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

4.0.2 patch release breaks GDExtension API #75779

Closed
Bromeon opened this issue Apr 7, 2023 · 4 comments
Closed

4.0.2 patch release breaks GDExtension API #75779

Bromeon opened this issue Apr 7, 2023 · 4 comments

Comments

@Bromeon
Copy link
Contributor

Bromeon commented Apr 7, 2023

Godot version

4.0.2-stable

System information

Windows 10

Issue description

Here are the diffs of extension_api.json between patch versions of the Godot 4.0 range:

v4.0 -> v4.0.1
diff --git a/v40.json b/v401.json
index 5814731cde..b432cdaa5a 100644
--- a/v40.json
+++ b/v401.json
@@ -2,10 +2,10 @@
 	"header": {
 		"version_major": 4,
 		"version_minor": 0,
-		"version_patch": 0,
+		"version_patch": 1,
 		"version_status": "stable",
 		"version_build": "official",
-		"version_full_name": "Godot Engine v4.0.stable.official"
+		"version_full_name": "Godot Engine v4.0.1.stable.official"
 	},
 	"builtin_class_sizes": [
 		{
@@ -1915,9 +1915,7 @@
 			]
 		}
 	],
-	"global_constants": [
-
-	],
+	"global_constants": [],
 	"global_enums": [
 		{
 			"name": "Side",
@@ -123544,7 +123542,7 @@
 					"getter": "is_flat"
 				},
 				{
-					"type": "bool",
+					"type": "int",
 					"name": "start_index",
 					"setter": "set_start_index",
 					"getter": "get_start_index"
@@ -267318,11 +267316,11 @@
 		},
 		{
 			"name": "PhysicsServer3DExtensionMotionCollision",
-			"format": "Vector3 position;Vector3 normal;Vector3 collider_velocity;real_t depth;int local_shape;ObjectID collider_id;RID collider;int collider_shape"
+			"format": "Vector3 position;Vector3 normal;Vector3 collider_velocity;Vector3 collider_angular_velocity;real_t depth;int local_shape;ObjectID collider_id;RID collider;int collider_shape"
 		},
 		{
 			"name": "PhysicsServer3DExtensionMotionResult",
-			"format": "Vector3 travel;Vector3 remainder;real_t collision_safe_fraction;real_t collision_unsafe_fraction;PhysicsServer3DExtensionMotionCollision collisions[32];int collision_count"
+			"format": "Vector3 travel;Vector3 remainder;real_t collision_depth;real_t collision_safe_fraction;real_t collision_unsafe_fraction;PhysicsServer3DExtensionMotionCollision collisions[32];int collision_count"
 		},
 		{
 			"name": "PhysicsServer3DExtensionRayResult",
v4.0.1 -> v4.0.2
diff --git a/v401.json b/v402.json
index b432cdaa5a..7514e2affe 100644
--- a/v401.json
+++ b/v402.json
@@ -1,13 +1,13 @@
 {
 	"header": {
 		"version_major": 4,
 		"version_minor": 0,
-		"version_patch": 1,
+		"version_patch": 2,
 		"version_status": "stable",
 		"version_build": "official",
-		"version_full_name": "Godot Engine v4.0.1.stable.official"
+		"version_full_name": "Godot Engine v4.0.2.stable.official"
 	},
 	"builtin_class_sizes": [
 		{
 			"build_configuration": "float_32",
 			"sizes": [
@@ -25214,11 +25214,11 @@
 					"name": "play",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 1459844657,
+					"hash": 2372066587,
 					"arguments": [
 						{
 							"name": "name",
 							"type": "StringName",
 							"default_value": "&\"\""
@@ -25658,11 +25658,11 @@
 					"name": "play",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 1459844657,
+					"hash": 2372066587,
 					"arguments": [
 						{
 							"name": "name",
 							"type": "StringName",
 							"default_value": "&\"\""
@@ -27759,11 +27759,11 @@
 					"name": "compress",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 1804059263,
+					"hash": 3608408117,
 					"arguments": [
 						{
 							"name": "page_size",
 							"type": "int",
 							"meta": "uint32",
@@ -31333,11 +31333,11 @@
 					"name": "play",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 2221377757,
+					"hash": 3118260607,
 					"arguments": [
 						{
 							"name": "name",
 							"type": "StringName",
 							"default_value": "\"\""
@@ -39804,11 +39804,11 @@
 					"name": "play",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 3041634712,
+					"hash": 1958160172,
 					"arguments": [
 						{
 							"name": "from_position",
 							"type": "float",
 							"meta": "float",
@@ -40164,11 +40164,11 @@
 					"name": "play",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 3041634712,
+					"hash": 1958160172,
 					"arguments": [
 						{
 							"name": "from_position",
 							"type": "float",
 							"meta": "float",
@@ -40721,11 +40721,11 @@
 					"name": "play",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 3041634712,
+					"hash": 1958160172,
 					"arguments": [
 						{
 							"name": "from_position",
 							"type": "float",
 							"meta": "float",
@@ -56072,11 +56072,11 @@
 					"name": "draw_set_transform",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 4181505845,
+					"hash": 3283884939,
 					"arguments": [
 						{
 							"name": "position",
 							"type": "Vector2"
 						},
@@ -58296,10 +58296,18 @@
 					"hash": 2240911060,
 					"return_value": {
 						"type": "bool"
 					}
 				},
+				{
+					"name": "apply_floor_snap",
+					"is_const": false,
+					"is_vararg": false,
+					"is_static": false,
+					"is_virtual": false,
+					"hash": 3218959716
+				},
 				{
 					"name": "set_velocity",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
@@ -59023,10 +59031,18 @@
 					"hash": 2240911060,
 					"return_value": {
 						"type": "bool"
 					}
 				},
+				{
+					"name": "apply_floor_snap",
+					"is_const": false,
+					"is_vararg": false,
+					"is_static": false,
+					"is_virtual": false,
+					"hash": 3218959716
+				},
 				{
 					"name": "set_velocity",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
@@ -69643,11 +69659,11 @@
 					"name": "sample_baked",
 					"is_const": true,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 3750540263,
+					"hash": 3464257706,
 					"return_value": {
 						"type": "Vector2"
 					},
 					"arguments": [
 						{
@@ -69667,11 +69683,11 @@
 					"name": "sample_baked_with_rotation",
 					"is_const": true,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 255128112,
+					"hash": 3296056341,
 					"return_value": {
 						"type": "Transform2D"
 					},
 					"arguments": [
 						{
@@ -69762,11 +69778,11 @@
 					"name": "tessellate_even_length",
 					"is_const": true,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 4229237857,
+					"hash": 2319761637,
 					"return_value": {
 						"type": "PackedVector2Array"
 					},
 					"arguments": [
 						{
@@ -70145,11 +70161,11 @@
 					"name": "sample_baked",
 					"is_const": true,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 4240323138,
+					"hash": 1350085894,
 					"return_value": {
 						"type": "Vector3"
 					},
 					"arguments": [
 						{
@@ -70169,11 +70185,11 @@
 					"name": "sample_baked_with_rotation",
 					"is_const": true,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 2486289007,
+					"hash": 1939359131,
 					"return_value": {
 						"type": "Transform3D"
 					},
 					"arguments": [
 						{
@@ -70314,11 +70330,11 @@
 					"name": "tessellate_even_length",
 					"is_const": true,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 3915530683,
+					"hash": 133237049,
 					"return_value": {
 						"type": "PackedVector3Array"
 					},
 					"arguments": [
 						{
@@ -74055,11 +74071,11 @@
 					"name": "tts_speak",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 3723082199,
+					"hash": 3741216677,
 					"arguments": [
 						{
 							"name": "text",
 							"type": "String"
 						},
@@ -91107,11 +91123,11 @@
 					"name": "find_variation",
 					"is_const": true,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 3705324482,
+					"hash": 1149405976,
 					"return_value": {
 						"type": "RID"
 					},
 					"arguments": [
 						{
@@ -106335,11 +106351,11 @@
 					"name": "make_baked_meshes",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 1135556294,
+					"hash": 3609286057,
 					"arguments": [
 						{
 							"name": "gen_lightmap_uv",
 							"type": "bool",
 							"default_value": "false"
@@ -109096,11 +109112,11 @@
 					"name": "save_jpg_to_buffer",
 					"is_const": true,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 310747435,
+					"hash": 592235273,
 					"return_value": {
 						"type": "PackedByteArray"
 					},
 					"arguments": [
 						{
@@ -109183,11 +109199,11 @@
 					"name": "save_webp_to_buffer",
 					"is_const": true,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 1235769281,
+					"hash": 1214628238,
 					"return_value": {
 						"type": "PackedByteArray"
 					},
 					"arguments": [
 						{
@@ -109387,11 +109403,11 @@
 					"name": "bump_map_to_normal_map",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 336773324,
+					"hash": 3423495036,
 					"arguments": [
 						{
 							"name": "bump_scale",
 							"type": "float",
 							"meta": "float",
@@ -149297,11 +149313,11 @@
 					"name": "move_and_collide",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 3198110832,
+					"hash": 1529961754,
 					"return_value": {
 						"type": "KinematicCollision2D"
 					},
 					"arguments": [
 						{
@@ -149415,11 +149431,11 @@
 					"name": "move_and_collide",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 1140990067,
+					"hash": 2825704414,
 					"return_value": {
 						"type": "KinematicCollision3D"
 					},
 					"arguments": [
 						{
@@ -149454,11 +149470,11 @@
 					"name": "test_move",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 2082761915,
+					"hash": 680299713,
 					"return_value": {
 						"type": "bool"
 					},
 					"arguments": [
 						{
@@ -152311,11 +152327,11 @@
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
 					"hash": 3803848594,
 					"return_value": {
-						"type": "typedarray::PackedVector2Array"
+						"type": "typedarray::Vector2"
 					},
 					"arguments": [
 						{
 							"name": "parameters",
 							"type": "PhysicsShapeQueryParameters2D"
@@ -152754,11 +152770,11 @@
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
 					"hash": 550215980,
 					"return_value": {
-						"type": "typedarray::PackedVector3Array"
+						"type": "typedarray::Vector3"
 					},
 					"arguments": [
 						{
 							"name": "parameters",
 							"type": "PhysicsShapeQueryParameters3D"
@@ -175606,11 +175622,11 @@
 					"name": "randfn",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 2207676613,
+					"hash": 837325100,
 					"return_value": {
 						"type": "float",
 						"meta": "float"
 					},
 					"arguments": [
@@ -189939,11 +189955,11 @@
 					"name": "environment_set_ambient_light",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 362573166,
+					"hash": 491659071,
 					"arguments": [
 						{
 							"name": "env",
 							"type": "RID"
 						},
@@ -192722,11 +192738,11 @@
 					"name": "canvas_item_set_canvas_group_mode",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 1568036344,
+					"hash": 41973386,
 					"arguments": [
 						{
 							"name": "item",
 							"type": "RID"
 						},
@@ -193743,11 +193759,11 @@
 					"name": "force_draw",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 899045543,
+					"hash": 1076185472,
 					"arguments": [
 						{
 							"name": "swap_buffers",
 							"type": "bool",
 							"default_value": "true"
@@ -263388,11 +263404,11 @@
 					"name": "popup_centered_ratio",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 1912078273,
+					"hash": 1014814997,
 					"arguments": [
 						{
 							"name": "ratio",
 							"type": "float",
 							"meta": "float",
@@ -263419,11 +263435,11 @@
 					"name": "popup_centered_clamped",
 					"is_const": false,
 					"is_vararg": false,
 					"is_static": false,
 					"is_virtual": false,
-					"hash": 3728566557,
+					"hash": 2613752477,
 					"arguments": [
 						{
 							"name": "minsize",
 							"type": "Vector2i",
 							"default_value": "Vector2i(0, 0)"
@@ -266670,10 +266686,35 @@
 							"type": "float",
 							"meta": "double"
 						}
 					]
 				},
+				{
+					"name": "get_world_origin",
+					"is_const": true,
+					"is_vararg": false,
+					"is_static": false,
+					"is_virtual": false,
+					"hash": 3229777777,
+					"return_value": {
+						"type": "Transform3D"
+					}
+				},
+				{
+					"name": "set_world_origin",
+					"is_const": false,
+					"is_vararg": false,
+					"is_static": false,
+					"is_virtual": false,
+					"hash": 2952846383,
+					"arguments": [
+						{
+							"name": "world_origin",
+							"type": "Transform3D"
+						}
+					]
+				},
 				{
 					"name": "get_reference_frame",
 					"is_const": true,
 					"is_vararg": false,
 					"is_static": false,
@@ -266951,10 +266992,16 @@
 					"type": "float",
 					"name": "world_scale",
 					"setter": "set_world_scale",
 					"getter": "get_world_scale"
 				},
+				{
+					"type": "Vector3",
+					"name": "world_origin",
+					"setter": "set_world_origin",
+					"getter": "get_world_origin"
+				},
 				{
 					"type": "Object",
 					"name": "primary_interface",
 					"setter": "set_primary_interface",
 					"getter": "get_primary_interface"

In the diff to 4.0.1, a type bool is changed to int (MenuBar::start_index property). While technically a breaking change, this was a bug in the first place, so it should be OK.

In the diff to 4.0.2 however, several function hashes changed. And in fact Godot 4.0.2 can no longer invoke the functions with the older hash. I encountered this with AudioStreamPlayer::play (old hash 3041634712) and AnimatedSprite2D::play (old hash 1459844657).


Why did these hashes change?

If the change is intended, there should probably be a compatibility map, so that new functions can still be found using old hashes (this was the idea discussed before Godot 4, IIRC). Without a strategy here, every patch release can be major compatibility hazard for GDExtension, making it impossible to update Godot versions independently of the extension layer.

Steps to reproduce

In general:

  1. Compile the Godot bindings with engine version 4.0.1 (either godot-cpp or gdext).
  2. Use one of the calls above, e.g. AudioStreamPlayer::play.
  3. Run the code with engine version 4.0.2 -> error or UB.

See also below for a concrete, easy-to-reproduce example.

Minimal reproduction project

You can use godot-rust's vendored dodge-the-creeps example.

  1. Clone godot-rust/gdext@e3b9ad1.
  2. Run cargo build -p dodge-the-creeps from the cloned repo root.
  3. Godot_v4.0.2-stable_win64_console.exe --path examples\dodge-the-creeps\godot.
  4. Embrace the crash 🙂 (will be caught in the future)
@YuriSizov
Copy link
Contributor

Why did these hashes change?

Yeah, we noticed, but both me and @akien-mga don't have an idea why that happened.

@RedworkDE
Copy link
Member

All these methods have a float default argument. Not sure if worth reverting it in 4.0.3 and then having just 4.0.2 as the incompatible one, or if leaving is better and then having 4.0 and 4.0.1 as the incompatible ones.

bors bot added a commit to godot-rust/gdext that referenced this issue Apr 10, 2023
216: Catch failed calls to `classdb_get_method_bind()` r=Bromeon a=Bromeon

When Godot fails to provide a method (e.g. invalid hash), this FFI method returns a null pointer. Instead of UB from dereferencing that pointer, a panic is now caused.

Found as a result of godotengine/godot#75779.

Co-authored-by: Jan Haller <bromeon@gmail.com>
@vnen
Copy link
Member

vnen commented Apr 17, 2023

The changes in native structs is also problematic. Code using the old one would crash when interacting with the new.

@Bromeon
Copy link
Contributor Author

Bromeon commented Dec 19, 2023

Since we cannot fix this release anymore and the bug was patched in #74600, I'll close this issue.

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