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

time.parse_format breaks under -autofree #21369

Open
jrfondren opened this issue Apr 28, 2024 · 0 comments
Open

time.parse_format breaks under -autofree #21369

jrfondren opened this issue Apr 28, 2024 · 0 comments
Labels
Autofree Bugs/feature requests, that are related to -autofree. Bug This tag is applied to issues which reports bugs.

Comments

@jrfondren
Copy link
Contributor

jrfondren commented Apr 28, 2024

Describe the bug

Presumably this is a user-after-free bug introduced by autofree.

Reproduction Steps

import time

println(time.parse_format('04 Oct 2023', 'DD MMM YYYY') or { panic('???') })

Expected Behavior

Output from "v run":

2023-10-04 00:00:00

Current Behavior

Output from "v -autofree run" is inconsistent. Sometime the parse returns a v error when it shouldn't:

V panic: ???
v hash: 0e711f9
/tmp/v_1000/timebug.01HWH4PS2BK7CWC6TH4BYRGAYN.tmp.c:7317: at _v_panic: Backtrace
/tmp/v_1000/timebug.01HWH4PS2BK7CWC6TH4BYRGAYN.tmp.c:16007: by main__main
/tmp/v_1000/timebug.01HWH4PS2BK7CWC6TH4BYRGAYN.tmp.c:16083: by main

And sometimes the parse panics:

V panic: substr(0, -706054738) out of bounds (len=11) s="04 Oct 2023"
v hash: 0e711f9
/tmp/v_1000/timebug.01HWH4QM33K65PGQSPS9BGFDWY.tmp.c:7317: at _v_panic: Backtrace
/tmp/v_1000/timebug.01HWH4QM33K65PGQSPS9BGFDWY.tmp.c:10894: by string_substr
/tmp/v_1000/timebug.01HWH4QM33K65PGQSPS9BGFDWY.tmp.c:13384: by time__DateTimeParser_next
/tmp/v_1000/timebug.01HWH4QM33K65PGQSPS9BGFDWY.tmp.c:13463: by time__DateTimeParser_must_be_string
/tmp/v_1000/timebug.01HWH4QM33K65PGQSPS9BGFDWY.tmp.c:13816: by time__DateTimeParser_parse
/tmp/v_1000/timebug.01HWH4QM33K65PGQSPS9BGFDWY.tmp.c:15022: by time__parse_format
/tmp/v_1000/timebug.01HWH4QM33K65PGQSPS9BGFDWY.tmp.c:16004: by main__main
/tmp/v_1000/timebug.01HWH4QM33K65PGQSPS9BGFDWY.tmp.c:16083: by main

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.5 0e711f9

Environment details (OS name and version, etc.)

V full version: V 0.4.5 149cbba.0e711f9
OS: linux, Linux version 5.14.0-362.24.1.el9_3.x86_64 ([email protected]) (gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2), GNU ld version 2.35.2-42.el9_3.1) #1 SMP PREEMPT_DYNAMIC Wed Mar 13 17:33:16 UTC 2024
Processor: 16 cpus, 64bit, little endian, AMD Ryzen 7 7840HS w/ Radeon 780M Graphics

vexe mtime: 2024-04-27 22:30:08

VTMP: OK, value: /tmp/v_1000

Git version: git version 2.39.3
Git vroot status: weekly.2024.17-41-g0e711f9f
.git/config present: true

CC version: cc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2)
thirdparty/tcc status: thirdparty-linux-amd64 40e5cbb5

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.

@jrfondren jrfondren added the Bug This tag is applied to issues which reports bugs. label Apr 28, 2024
@felipensp felipensp added the Autofree Bugs/feature requests, that are related to -autofree. label May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Autofree Bugs/feature requests, that are related to -autofree. Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

2 participants