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

_vcleanup crashes when importing time with -autofree #21212

Open
spiveeworks opened this issue Apr 7, 2024 · 0 comments
Open

_vcleanup crashes when importing time with -autofree #21212

spiveeworks opened this issue Apr 7, 2024 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs. OS: Windows Bugs/feature requests, that are specific to Windows OS.

Comments

@spiveeworks
Copy link
Contributor

spiveeworks commented Apr 7, 2024

Describe the bug

When importing time and compiling with -autofree, if main returns, then during _vcleanup the program tries to call array_free on _const_time__long_days, which is a fixed sized array. This is an instance of #21211 but could be worked around in the mean time.

	array_free(&_const_time__long_days);

Reproduction Steps

import time

println("${time.now()}")

run with v -autofree run time_autofree_bug.v

Expected Behavior

I expect it to print the current time and then exit cleanly.

Current Behavior

It prints the current time, and then crashes.

2024-04-07 15:35:42
Unhandled Exception 0xC0000374
15: RtlIsZeroMemory            ?? : address = 0x23fa1d08350
14: RtlIsZeroMemory            ?? : address = 0x23fa1d08e40
13: RtlpNtSetValueKey          ?? : address = 0x23fa4b2d520
12: RtlpNtSetValueKey          ?? : address = 0x23fa4b2db60
11: RtlpNtSetValueKey          ?? : address = 0x23fa4b2e510
10: RtlGetCurrentServiceSessionId  ?? : address = 0x23fa4b2f320
9 : RtlFreeHeap                ?? : address = 0x23fa4b2edd0
8 : NotifyShims                ?? : address = 0x23fa4b2eba0
7 : free_base                  ?? : address = 0x23fa4b2fe60
6 : v_free                     ?? : address = 0x23fa4b30e00
5 : array_free                 ?? : address = 0x23fa4b312b0
4 : vcleanup                   ?? : address = 0x23fa4b42f60
3 : wmain                      ?? : address = 0x23fa4b431e0
2 : __scrt_common_main_seh     D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
1 : BaseThreadInitThunk        ?? : address = 0x23fa4b43e10
0 : RtlUserThreadStart         ?? : address = 0x23fa4b444a0

Possible Solution

_const_time__long_days is a Array_fixed_string_7, i.e. a [7]string, not a []string, and so cgen shouldn't be calling array_free on it.

Its definition is here:
https://github.com/vlang/v/blob/master/vlib/time/time.v#L4

Looking at long_months in the same file, long_months is not declared with []!, possibly as a workaround to this same bug. In the short term making long_days not fixed-size would work around this problem, but fixing the actual bug itself: #21211 would solve it properly.

Additional Information/Context

Running on Windows with msvc.

V version

V 0.4.5 ad17be5

Environment details (OS name and version, etc.)

V full version: V 0.4.5 386bd77.ad17be5
OS: windows, Microsoft Windows 10 Pro v19045 64-bit
Processor: 4 cpus, 64bit, little endian,

getwd: C:\Users\Owner\Code\v-experiments
vexe: C:\Program Files\v\v.exe
vexe mtime: 2024-04-07 05:22:56

vroot: contains spaces, value: C:\Program Files\v
VMODULES: OK, value: C:\Users\Owner\.vmodules
VTMP: OK, value: C:\Users\Owner\AppData\Local\Temp\v_0

Git version: git version 2.37.2.windows.2
Git vroot status: 0.4.5-113-gad17be5d
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.

thirdparty/tcc: N/A

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.

@spiveeworks spiveeworks added the Bug This tag is applied to issues which reports bugs. label Apr 7, 2024
@felipensp felipensp added the OS: Windows Bugs/feature requests, that are specific to Windows OS. label Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. OS: Windows Bugs/feature requests, that are specific to Windows OS.
Projects
None yet
Development

No branches or pull requests

2 participants