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

Server crash - Lua _deflua_make_partisans_callback() #1161

Closed
jwrober opened this issue Jul 25, 2022 · 1 comment · Fixed by #1177
Closed

Server crash - Lua _deflua_make_partisans_callback() #1161

jwrober opened this issue Jul 25, 2022 · 1 comment · Fixed by #1177
Labels
bug Something isn't working Untriaged This issue or PR needs triaging

Comments

@jwrober
Copy link
Collaborator

jwrober commented Jul 25, 2022

Describe the bug

[critical] freeciv21-server (../common/scriptcore/luascript.cpp:453) - T417: lua error:       stack index 2, expected number, received number: not a numeric type that fits exactly an integer (number maybe has significant decimals) (bad argument into 'int(int, int)')
stack traceback:
        [C]: in function 'random'
        data/default/default.lua:191: in function '_deflua_make_partisans_callback'

To Reproduce
Steps to reproduce the behavior:

  1. Start a game, use a savegame or run an autogame to get up to partisans
  2. Build a partisan
  3. See error

Expected behavior
No server crash on the Lua callback

Screenshots
N/A

Platform and version (please complete the following information):

  • OS: Linux (but assume its everywhere)
  • Freeciv21 version: 3.0-beta3
  • Ruleset/Longturn game (if applicable): classic

Additional context
None

@jwrober jwrober added bug Something isn't working Untriaged This issue or PR needs triaging labels Jul 25, 2022
@lmoureaux
Copy link
Contributor

This line from default.lua looks weird:

  local partisans = random(0, 1 + (city.size + 1) / 2) + 1

The upper bound in the random() call will be fractional if city.size is even. We need to floor() it explicitly or disable the check in sol2.

lmoureaux added a commit to lmoureaux/freeciv21 that referenced this issue Jul 31, 2022
tolua was implicitly converting floats to ints, but sol2 chokes on this. For
backward compatibility and to fix our own rulesets, disable this check in sol.

Closes longturn#1161.
lmoureaux added a commit that referenced this issue Aug 2, 2022
tolua was implicitly converting floats to ints, but sol2 chokes on this. For
backward compatibility and to fix our own rulesets, disable this check in sol.

Closes #1161.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Untriaged This issue or PR needs triaging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants