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

Some undefined behavior found in bbMilliSecs() #277

Open
AXKuhta opened this issue Jun 4, 2023 · 0 comments
Open

Some undefined behavior found in bbMilliSecs() #277

AXKuhta opened this issue Jun 4, 2023 · 0 comments

Comments

@AXKuhta
Copy link

AXKuhta commented Jun 4, 2023

I'm using BlitzMax on Ubuntu 23.04 with some sanitizer options in my custom.bmk:

setccopt fortify -D_FORTIFY_SOURCE=3
setccopt undefined -fsanitize=undefined
setccopt udtrap -fsanitize-undefined-trap-on-error

It all worked well up until today, when a month old binary suddenly started crashing on ud2 on startup. It crashed right here.

Workaround:

--- a/blitz_app.c
+++ b/blitz_app.c
@@ -212,7 +212,7 @@ void bbUDelay( int microseconds ) {
 
 //***** ThreadSafe! *****
 int bbMilliSecs(){
-       int t;
+       unsigned int t;
        struct timeval tv;
        gettimeofday(&tv,0);
        t=tv.tv_sec*1000;

Real solution would probably involve switching to 64 bit time?

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

No branches or pull requests

1 participant