time: Duration.debug prints only a minus sign at min_i64
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
Research direction
The bug is in the time module's Duration.debug() method, which negates the signed nanosecond count to get a magnitude, so min_i64 overflows. Start by reading Duration.debug in vlib/time and reproduce with the snippet in the issue using ./v -gc none run repro.v. Done when min_i64 prints the full magnitude (106751days, 23h, 47m, 16s, 854ms, 775us, 808ns) and a regression test covers it.
Written by the indexing model from the issue text.
Description
On dev at 9cc1ed5b96, run this with ./v -gc none run repro.v:
import time
fn main() {
println(time.Duration(min_i64).debug())
}
It prints Duration: - . The expected output is Duration: - 106751days, 23h, 47m, 16s, 854ms, 775us, 808ns.
Duration.debug() negates the signed nanosecond count to get its magnitude. The magnitude of min_i64 fits in u64, but negating it as i64 overflows. Clang's signed-integer-overflow sanitizer reports the negation.
[!NOTE]
You can use the 👍 reaction to increase the issue's priority for developers.Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
- Dominant language
- V
- Stars
- 38.1k
- Forks
- 2.3k
- Avg merge
- 22h 8m
- Merged PRs (30d)
- 636
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vlang/v
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
datatypes: RingBuffer retains references to popped elementsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 Half a day Newbie friendliness 64/100
TigreGotico/orthography2ipa#2595 ·
Maintainers usually reply within 1 day
-
bug difficulty:2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
MakazhanAlpamys/Soup#3342 · 1 comment ·
Maintainers usually reply within 1 day
-
bug Next.js
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
getsentry/sentry-wizard#1397 · 1 comment ·
Maintainers usually reply within 1 day
-
area: api enhancement
Difficulty 2/5 Half a day Newbie friendliness 72/100
eddiejaoude/gh-notif-clean#56 ·
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
floorianmb/tidywise#1 ·