Telemetry SDK: game crashes when registered for wheel lift on truck without liftable wheels

Post Reply
Posts: 27
Joined: 07 Dec 2016 13:28

Telemetry SDK: game crashes when registered for wheel lift on truck without liftable wheels

#1 Post by jonathan2520 » 10 Aug 2017 19:33

If you're registered for SCS_TELEMETRY_TRUCK_CHANNEL_wheel_lift or SCS_TELEMETRY_TRUCK_CHANNEL_wheel_lift_offset, and your truck doesn't have a single liftable wheel, the game crashes just before it would deliver that data to the callback. I'd expect to get the value zero, as with non-liftable wheels on a truck that has liftable wheels. Not null (unless the truck doesn't have that wheel altogether), and certainly not a crash.

Reproduce with this code:

Code: Select all

#include <cstdio>
#include <cinttypes>
#include "scssdk_telemetry.h"
#include "common/scssdk_telemetry_truck_common_channels.h"

static scs_telemetry_init_params_v100_t params_copy;

static void callback(const scs_string_t name, const scs_u32_t index, const scs_value_t * const value, const scs_context_t context)
	char buffer[128];
	if (value)
		std::snprintf(buffer, sizeof buffer, "%s[%" PRIu32 "] = %.9g", name, index, value->value_float.value);
		std::snprintf(buffer, sizeof buffer, "%s[%" PRIu32 "] = null", name, index);
	params_copy.common.log(SCS_LOG_TYPE_message, buffer);

SCSAPI_RESULT scs_telemetry_init(const scs_u32_t version, const scs_telemetry_init_params_t * const params)
	if (version != SCS_TELEMETRY_VERSION_1_00)
		return SCS_RESULT_unsupported;
	params_copy = *static_cast<const scs_telemetry_init_params_v100_t *>(params);
	params_copy.register_for_channel(SCS_TELEMETRY_TRUCK_CHANNEL_wheel_rotation, 0, SCS_VALUE_TYPE_float, SCS_TELEMETRY_CHANNEL_FLAG_no_value, callback, nullptr);
	params_copy.register_for_channel(SCS_TELEMETRY_TRUCK_CHANNEL_wheel_lift, 0, SCS_VALUE_TYPE_float, SCS_TELEMETRY_CHANNEL_FLAG_no_value, callback, nullptr);
	params_copy.register_for_channel(SCS_TELEMETRY_TRUCK_CHANNEL_wheel_lift_offset, 0, SCS_VALUE_TYPE_float, SCS_TELEMETRY_CHANNEL_FLAG_no_value, callback, nullptr);
	return SCS_RESULT_ok;

SCSAPI_VOID scs_telemetry_shutdown(void)
game.log.txt. In this run I started with my current main truck which has a midlift chassis. That's all fine even though the wheel I've registered for isn't liftable. Then I relocated to a 4x2. I got to see one frame or so in that truck before it crashed. You can also see that the log ends at the first truck.wheel.rotation of that truck, just before I would receive truck.wheel.lift. According to the system's crash log, it crashes somewhere in the game, not in my code:

Code: Select all

Crashed Thread:        0  MainThrd  Dispatch queue:

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000020
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

VM Regions Near 0x20:
    __TEXT                 00000001052aa000-0000000106396000 [ 16.9M] r-x/rwx SM=COW  /Users/USER/Library/Application Support/Steam/*/Euro Truck Simulator

Thread 0 Crashed:: MainThrd  Dispatch queue:
0   com.scssoft.ets2              	0x000000010591adde 0x1052aa000 + 6753758
1   com.scssoft.ets2              	0x00000001058afe9d 0x1052aa000 + 6315677
2   com.scssoft.ets2              	0x0000000105f20214 0x1052aa000 + 13066772
3   com.scssoft.ets2              	0x0000000105f19800 0x1052aa000 + 13039616
4   com.scssoft.ets2              	0x000000010539a2aa 0x1052aa000 + 983722
5   com.scssoft.ets2              	0x00000001059e8f1f 0x1052aa000 + 7597855
6   com.scssoft.ets2              	0x0000000105d71a45 0x1052aa000 + 11303493
7   com.scssoft.ets2              	0x0000000105d66195 0x1052aa000 + 11256213
8   com.scssoft.ets2              	0x00000001052ab9b3 0x1052aa000 + 6579
9   libdyld.dylib                 	0x00007fffbf0ec235 start + 1
Address 0x20 which it's trying to access must be a small offset from a null pointer. If you don't register for truck.wheel.lift, you'll find it does the same thing in nearby code for truck.wheel.lift.offset.

Version, 64-bit, on macOS 10.12.6.

Post Reply

Return to “Bugs 1.28”

Who is online

Users browsing this forum: No registered users and 7 guests