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

Fix use of unsafe localtime() and portable gmtime_r() #1481

Merged
merged 1 commit into from
Aug 19, 2021

Conversation

XVilka
Copy link
Member

@XVilka XVilka commented Aug 19, 2021

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the documentation and the rizin book with the relevant information (if needed)

Detailed description

Some code was using thread-unsafe localtime(), some code was using non-portable gmtime_r(). I created own portable rz_gmtime_r() in analogy to existing rz_localtime_r() and used it instead. Also removed unnecessary inline function from the header.

Test plan

CI is green.

Closing issues

Might be related to #982 (comment)

@XVilka XVilka added this to the 0.3.0 milestone Aug 19, 2021
@XVilka XVilka requested a review from kazarmy as a code owner August 19, 2021 08:34
@github-actions github-actions bot added the API label Aug 19, 2021
@XVilka
Copy link
Member Author

XVilka commented Aug 19, 2021

I noticed a strange bug recently, sometimes it happens on Alpine Linux like in this PR:

[XX] db/tools/rz_ax rz-ax -t "1234567890 GMT-1"
RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc '!rz-ax -t "1234567890 GMT-1" | cut -d " " -f 1,2' =
-- stdout
--- expected
+++ actual
@@ -1,1 +1,1 @@
-Fri Feb
+Sat Jun

See https://github.com/rizinorg/rizin/pull/1481/checks?check_run_id=3369716223#step:8:3159

Sometimes it happens on Windows:

[XX] C:\projects\rizin\test\db\tools\rz_ax rz-ax -t "1234567890 GMT-1"
ANSICON=1 RZ_NOPLUGINS=1 rizin -escr.utf8=0 -escr.color=0 -escr.interactive=0 -N -Qc '!rz-ax -t "1234567890 GMT-1" | cut -d " " -f 1,2' =
-- stdout
--- expected
+++ actual
@@ -1,1 +1,1 @@
-Fri Feb
+Mon Aug
[**]              C:\projects\rizin\test\db\tools\rz_ax      379 OK         9 BR        1 XX        5 FX

(See https://ci.appveyor.com/project/rizinorg/rizin/builds/40439023/job/guyflnbj6rm6chrm#L3464 - it's another, unrelated branch).

Is someone has any clues - please let me know.

Note, that this PR should be merged anyway, even if those bugs aren't fixed - it already improves the portability and thread-safety.

@wargio
Copy link
Member

wargio commented Aug 19, 2021

timezone

@pelijah
Copy link
Contributor

pelijah commented Aug 19, 2021

I just ignore these timezone related fails.

@XVilka
Copy link
Member Author

XVilka commented Aug 19, 2021

Ideally, the time decoding commands/functions in Rizin should not depend on the timezone.

Copy link
Member

@ret2libc ret2libc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually ignore those errors as well. They happen all the time on my machine.

@wargio wargio merged commit 4d3d227 into dev Aug 19, 2021
@wargio wargio deleted the dist-asan-time-travel branch August 19, 2021 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants