arnodel / golua

A Lua compiler / runtime in Go
Apache License 2.0
93 stars 10 forks source link

Fix overflow on 32-bit archs #98

Closed TheCount closed 1 year ago

TheCount commented 1 year ago

packFormatReader uses an uint for its option size, so maxDecuplable must not overflow uint. This happened on 32-bit archs and is fixed with this PR.

codecov[bot] commented 1 year ago

Codecov Report

Base: 87.72% // Head: 87.72% // No change to project coverage :thumbsup:

Coverage data is based on head (41441c6) compared to base (0907c3f). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## lua5.4 #98 +/- ## ======================================= Coverage 87.72% 87.72% ======================================= Files 107 107 Lines 11475 11475 ======================================= Hits 10067 10067 Misses 1088 1088 Partials 320 320 ``` | [Impacted Files](https://codecov.io/gh/arnodel/golua/pull/98?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Arnaud+Delobelle) | Coverage Δ | | |---|---|---| | [lib/stringlib/packformatreader.go](https://codecov.io/gh/arnodel/golua/pull/98?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Arnaud+Delobelle#diff-bGliL3N0cmluZ2xpYi9wYWNrZm9ybWF0cmVhZGVyLmdv) | `93.47% <ø> (ø)` | | | [runtime/value.go](https://codecov.io/gh/arnodel/golua/pull/98?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Arnaud+Delobelle#diff-cnVudGltZS92YWx1ZS5nbw==) | `86.37% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Arnaud+Delobelle). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Arnaud+Delobelle)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

TheCount commented 1 year ago

There appears to be another overflow bug:

--- FAIL: TestRuntime (0.39s)
    --- FAIL: TestRuntime/lua/basic.quotas.lua (0.04s)
        runtests.go:77: [output line 5, source line 44] expected: "done\t3736710778780434371", got: "done\t-980107325"
FAIL

I'll try to expand this pull request accordingly.

TheCount commented 1 year ago

The problem is with runtime.Value.ToString. Will post a fix shortly.

TorchedSammy commented 1 year ago

i noticed this too and did a fix like https://github.com/arnodel/golua/commit/fc92e663c7ad82845f7e4eddd24f0f34b7530834 on my fork

arnodel commented 1 year ago

Looks good, thanks for this.