Hemiptera Bugtracker at bugs.linux-forks.de

advtrains

Persistent crash after placing a train

Send replies to 182@bugs.linux-forks.de or using the Form below.
avatar From: OP
Thu, 17 Jun 2021 18:55:01 -0000

This is commit e5060860, master branch.

A player was trying to place a train on rails:

```

<xxxxxx> I placed an MT Siberling Cab Car on a track and it turned out to be off of the track, the track was at a ~22.5 degree rotation

```

This triggered a persistent crash -- the server now can't restart, it keeps repeating the same crash.

As a workaround to at least get the server running again, I changed the last part of advtrains_modpack/advtrains/path.lua to read as below.

I doubt this is a proper fix -- no, it's a kludge :-P

Since I don't know the advtrains codebase, I can't guess what negative effect this will have.

The player who triggered the crash reports that it works fine with this change in place.

```lua

354 -- How we'll adjust c_idx

355 -- Desired position: -------#------

356 -- Path items : --|--|--|--|--

357 -- c_idx : ^

358

359 while train.path_dist[c_idx] and train.path_dist[c_idx] < end_dist do

360 c_idx = c_idx + 1

361 end

362

363 while train.path_dist[c_idx] and train.path_dist[c_idx] > end_dist do

364 c_idx = c_idx - 1

365 end

366

367 -- Step 4: now c_idx points to the place shown above. Find out the fractional part.

368

369 if not train.path_dist[c_idx] or not train.path_dist[c_idx+1] then return 0 end

370

371 dist1, dist2 = train.path_dist[c_idx], train.path_dist[c_idx+1]

```

I don't know if it's even slightly related, but once it came back up, there was an undeclared global warning:

```

2021-06-17 18:12:56: WARNING[Server]: Undeclared global variable "pname" accessed at ...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:142

```

Here's the full crash backtrace:

```

2021-06-17 17:46:53: ACTION[Main]: Server: Shutting down

Number of Players: 0

2021-06-17 17:46:53: ACTION[Main]: [advtrains]Saved advtrains save files, took 4 ms

2021-06-17 17:46:53: WARNING[Main]: [advtrains]Train nil : Illegal path invalidation has occured during train step:

2021-06-17 17:46:53: WARNING[Main]: [advtrains]stack traceback:

...ble_World/worldmods/advtrains_modpack/advtrains/path.lua:117: in function 'path_invalidate'

...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:1354: in function 'invalidate_path'

...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:1335: in function 'invalidate_all_paths'

...ble_World/worldmods/advtrains_modpack/advtrains/init.lua:679: in function <...ble_World/worldmods/advtrains_modpack/advtrains/init.lua:651>

/usr/share/minetest/builtin/game/register.lua:425: in function </usr/share/minetest/builtin/game/register.lua:409>

2021-06-17 17:46:53: WARNING[Main]: [advtrains]Train nil : Illegal path invalidation has occured during train step:

2021-06-17 17:46:53: WARNING[Main]: [advtrains]stack traceback:

...ble_World/worldmods/advtrains_modpack/advtrains/path.lua:117: in function 'path_invalidate'

...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:1354: in function 'invalidate_path'

...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:1335: in function 'invalidate_all_paths'

...ble_World/worldmods/advtrains_modpack/advtrains/init.lua:679: in function <...ble_World/worldmods/advtrains_modpack/advtrains/init.lua:651>

/usr/share/minetest/builtin/game/register.lua:425: in function </usr/share/minetest/builtin/game/register.lua:409>

2021-06-17 17:46:53: WARNING[Main]: [advtrains]Train nil : Illegal path invalidation has occured during train step:

2021-06-17 17:46:53: WARNING[Main]: [advtrains]stack traceback:

...ble_World/worldmods/advtrains_modpack/advtrains/path.lua:117: in function 'path_invalidate'

...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:1354: in function 'invalidate_path'

...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:1335: in function 'invalidate_all_paths'

...ble_World/worldmods/advtrains_modpack/advtrains/init.lua:679: in function <...ble_World/worldmods/advtrains_modpack/advtrains/init.lua:651>

/usr/share/minetest/builtin/game/register.lua:425: in function </usr/share/minetest/builtin/game/register.lua:409>

2021-06-17 17:46:53: WARNING[Main]: [advtrains]Train nil : Illegal path invalidation has occured during train step:

2021-06-17 17:46:53: WARNING[Main]: [advtrains]stack traceback:

...ble_World/worldmods/advtrains_modpack/advtrains/path.lua:117: in function 'path_invalidate'

...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:1354: in function 'invalidate_path'

...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:1335: in function 'invalidate_all_paths'

...ble_World/worldmods/advtrains_modpack/advtrains/init.lua:679: in function <...ble_World/worldmods/advtrains_modpack/advtrains/init.lua:651>

/usr/share/minetest/builtin/game/register.lua:425: in function </usr/share/minetest/builtin/game/register.lua:409>

2021-06-17 17:46:54: ERROR[Main]: ServerError: AsyncErr: environment_Step: Runtime error from mod 'advtrains' in callback environment_Step(): ...ble_World/worldmods/advtrains_modpack/advtrains/path.lua:363: attempt to compare number with nil

2021-06-17 17:46:54: ERROR[Main]: stack traceback:

2021-06-17 17:46:54: ERROR[Main]: ...ble_World/worldmods/advtrains_modpack/advtrains/path.lua:363: in function 'path_get_index_by_offset'

2021-06-17 17:46:54: ERROR[Main]: ...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:226: in function 'recalc_end_index'

2021-06-17 17:46:54: ERROR[Main]: ...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:324: in function 'train_ensure_init'

2021-06-17 17:46:54: ERROR[Main]: ...rld/worldmods/advtrains_modpack/advtrains/trainlogic.lua:102: in function 'mainloop_trainlogic'

2021-06-17 17:46:54: ERROR[Main]: ...ble_World/worldmods/advtrains_modpack/advtrains/init.lua:608: in function 'func'

2021-06-17 17:46:54: ERROR[Main]: /usr/share/minetest/builtin/profiler/instrumentation.lua:106: in function </usr/share/minetest/builtin/profiler/instrumentation.lua:100>

2021-06-17 17:46:54: ERROR[Main]: /usr/share/minetest/builtin/game/register.lua:425: in function </usr/share/minetest/builtin/game/register.lua:409>

2021-06-17 17:46:54: ERROR[Main]: stack traceback:

```

--

"There are some things in life worth obsessing over.  Most

things aren't, and when you learn that, life improves."

Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com>

avatar From: Developer
Fri, 18 Jun 2021 20:54:01 -0000

Good that you found a workaround. Since this only ever happens when a train is off track, it should not break anything.

I will investigate this the next time I work on advtrains. Thanks for reporting.

Reply