Skip to content
This repository has been archived by the owner on Dec 2, 2019. It is now read-only.

Runtime error: unsigned integer overflow #774

Open
tanis2000 opened this issue Dec 3, 2018 · 4 comments
Open

Runtime error: unsigned integer overflow #774

tanis2000 opened this issue Dec 3, 2018 · 4 comments

Comments

@tanis2000
Copy link

It looks like on macOS and Web Assembly (but maybe other platforms as well) there are lots of integer overflows happening. Here's a sample from one of my apps:

../src/nuklear.h:13201:14: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:13201:14 in
../src/nuklear.h:10788:13: runtime error: unsigned integer overflow: 7735729 * 69069 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:10788:13 in
../src/nuklear.h:10790:18: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:10790:18 in
../src/nuklear.h:10791:19: runtime error: unsigned integer overflow: 4294967295 + 1 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:10791:19 in
../src/nuklear.h:12438:12: runtime error: unsigned integer overflow: 2 - 3 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:12438:12 in
../src/nuklear.h:12438:31: runtime error: unsigned integer overflow: 4294967295 + 1 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:12438:31 in
../src/nuklear.h:12438:47: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:12438:47 in
../src/nuklear.h:12438:66: runtime error: unsigned integer overflow: 4294967295 + 1 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:12438:66 in
../src/nuklear.h:6329:12: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'nk_size' (aka 'unsigned long')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:6329:12 in
../src/nuklear.h:12245:7: runtime error: unsigned integer overflow: 765 + 4294967041 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:12245:7 in
../src/nuklear.h:7172:4: runtime error: unsigned integer overflow: 1852399949 * 3432918353 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:7172:4 in
../src/nuklear.h:7174:4: runtime error: unsigned integer overflow: 690941820 * 461845907 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:7174:4 in
../src/nuklear.h:7178:8: runtime error: unsigned integer overflow: 2249103229 * 5 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:7178:8 in
../src/nuklear.h:7178:10: runtime error: unsigned integer overflow: 2655581553 + 3864292196 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:7178:10 in
../src/nuklear.h:7188:4: runtime error: unsigned integer overflow: 117 * 3432918353 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:7188:4 in
../src/nuklear.h:7190:4: runtime error: unsigned integer overflow: 1526907429 * 461845907 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:7190:4 in
../src/nuklear.h:7200:4: runtime error: unsigned integer overflow: 1344677135 * 2246822507 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:7200:4 in
../src/nuklear.h:7202:4: runtime error: unsigned integer overflow: 1761023207 * 3266489909 cannot be represented in type 'unsigned int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nuklear.h:7202:4 in

I'm not familiar with Nuklear's code base but I suppose that it's either because of something done in the wrong way or because of the 64bit platform it's being compiled against. Either way it would be nice to solve those issues as they prevent compiling to web assembly without activating the clamp option that actually produces dead slow code.

@dumblob
Copy link
Contributor

dumblob commented Dec 3, 2018

Could you please list all flags (https://github.com/vurtun/nuklear/blob/master/nuklear.h#L94 ) which you use for the compilation into web-assembly?

E.g. the integer overflows are solely dependent on these flags.

@tanis2000
Copy link
Author

Sure, here's the relevant code:

#define NK_INCLUDE_FIXED_TYPES
#define NK_INCLUDE_DEFAULT_FONT
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_INCLUDE_FONT_BAKING
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
#define NK_IMPLEMENTATION
#include "nuklear.h"

@dumblob
Copy link
Contributor

dumblob commented Dec 3, 2018

Did you define the following in your C files as well as in your header files?

#define NK_INCLUDE_FIXED_TYPES
#define NK_INCLUDE_DEFAULT_FONT
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_INCLUDE_FONT_BAKING
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT

@tanis2000
Copy link
Author

No, I have those in my C file only. There’s nothing about nuklear in the headers.
You can check out the actual code as I released it for the LD43 compo: https://tanis.itch.io/santa-frowns-to-town

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants