--- \dll\postgresql\a\backend\tcop\postgres.c	2019-11-23 13:19:20.000000000 -0300
+++ postgres.c	2019-11-24 11:13:34.131437500 -0300
@@ -3303,7 +3303,10 @@
 	/*
 	 * Compute distance from reference point to my local variables
 	 */
-	stack_depth = (long) (stack_base_ptr - &stack_top_loc);
+	if (stack_base_ptr != NULL)
+	    stack_depth = (long) (stack_base_ptr - &stack_top_loc);
+	else
+	    stack_depth = (long) &stack_top_loc;
 
 	/*
 	 * Take abs value, since stacks grow up on some machines, down on others
