godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.1k stars 21.18k forks source link

Long long int overflow in thirdparty/misc/open-simplex-noise.c #31291

Closed qarmin closed 4 years ago

qarmin commented 5 years ago

Godot version: 3.2.dev.custom_build. 3ea33c0e4

OS/device including version: Ubuntu 19.04

Issue description:

thirdparty/misc/open-simplex-noise.c:195:14: runtime error: signed integer overflow: 1442695040888963407 * 6364136223846793005 cannot be represented in type 'long int'
thirdparty/misc/open-simplex-noise.c:196:14: runtime error: signed integer overflow: 1876011003808476466 * 6364136223846793005 cannot be represented in type 'long int'
thirdparty/misc/open-simplex-noise.c:198:15: runtime error: signed integer overflow: -7280499659394350823 * 6364136223846793005 cannot be represented in type 'long int'
thirdparty/misc/open-simplex-noise.c:198:8: runtime error: signed integer overflow: 8903339076496225463 + 1442695040888963407 cannot be represented in type 'long long int'
thirdparty/misc/open-simplex-noise.c:194:14: runtime error: signed integer overflow: 2 * 6364136223846793005 cannot be represented in type 'long int'
thirdparty/misc/open-simplex-noise.c:195:7: runtime error: signed integer overflow: 8665214161362419545 + 1442695040888963407 cannot be represented in type 'long long int'
thirdparty/misc/open-simplex-noise.c:194:7: runtime error: signed integer overflow: 8301130017339275202 + 1442695040888963407 cannot be represented in type 'long long int'

and other similar when running different projects Steps to reproduce: Open empty project To see this error compile godot with this parameters

scons p=x11 -j6 use_ubsan=yes use_lsan=yes use_asan=yes
Anutrix commented 5 years ago

Maybe culprit is one among these https://lgtm.com/projects/g/godotengine/godot/alerts/?mode=list&id=cpp%2Finteger-multiplication-cast-to-long .

jeffkdev commented 4 years ago

Should be fixed now in source repo, see recent commits in: https://github.com/smcameron/open-simplex-noise-in-c Looks like it will have to be integrated with the Godot changes already in the file

aaronfranke commented 4 years ago

Should be fixed by this commit in upstream, and we just need to update our version: https://github.com/smcameron/open-simplex-noise-in-c/commit/0fef0dbedd76f767da7e3c894822729d0f07e54d

The latest master of that repo is 1 commit ahead of that commit.