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

Unhandled Exception 0x149f6f0 #23522

Open
koplenov opened this issue Jan 19, 2025 · 10 comments
Open

Unhandled Exception 0x149f6f0 #23522

koplenov opened this issue Jan 19, 2025 · 10 comments
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor.

Comments

@koplenov
Copy link
Contributor

koplenov commented Jan 19, 2025

V version: V 0.4.9 496451e, press to see full `v doctor` output
V full version V 0.4.9 4fcd94a.496451e
OS windows, Њ ©Єа®б®дв Windows 10 Pro 19045 64-а §ап¤­ п
Processor 28 cpus, 64bit, little endian, Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz
Memory 18.78GB/31.86GB
V executable C:\Dev\Progs\v\v.exe
V last modified time 2025-01-17 20:10:01
V home dir OK, value: C:\Dev\Progs\v
VMODULES OK, value: C:\Users\koplenov.vmodules
VTMP OK, value: C:\Users\koplenov\AppData\Local\Temp\v_0
Current working dir OK, value: C:\Dev\Zone\mam_v\treevee\src\repro
Git version git version 2.42.0.windows.2
V git status weekly.2025.1-72-g496451ec (12 commit(s) behind V master)
.git/config present true
cc version N/A
gcc version gcc (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r4) 13.2.0
clang version clang version 18.1.2
msvc version N/A
tcc version tcc version 0.9.27 (x86_64 Windows)
tcc git status thirdparty-windows-amd64 b425ac82
emcc version N/A
glibc version N/A

What did you do?
./v -g -o vdbg cmd/v && ./vdbg .\main.v && C:\Dev\Zone\mam_v\treevee\src\repro\main.exe

module main

pub struct Tree {
	value string
}
pub type TreeBelt = map[string]fn (input string) []string

fn main() {
	tree := Tree{
		value: 'he he'
	}

	mut belt := TreeBelt(map[string]fn (string) []string){
		"bar" : fn [tree](input string) []string {
			return [tree.value + input]
		}
	}

	mut belt2 := TreeBelt(map[string]fn (string) []string){}
	belt2['bar'] = fn [tree](input string) []string {
		return [tree.value + input]
	}

	// ok
	println(belt["bar"]) // fn (string) []string
	println(belt2["bar"]) // fn (string) []string


	println(belt["bar"]("foo")) // throw Unhandled Exception 0x149f6f0
	println(belt2["bar"]("fo")) // ok
}

What did you see?

fn (string) []string
fn (string) []string
Unhandled Exception 0x149f6f0
C:/Users/koplenov/AppData/Local/Temp/v_0/main.01JHZ9T7ZR1QFSFA4GXGBZQ1Q5.tmp.c:4464: at print_backtrace_skipping_top_frames_tcc: Backtrace
C:/Users/koplenov/AppData/Local/Temp/v_0/main.01JHZ9T7ZR1QFSFA4GXGBZQ1Q5.tmp.c:4450: by print_backtrace_skipping_top_frames
C:/Users/koplenov/AppData/Local/Temp/v_0/main.01JHZ9T7ZR1QFSFA4GXGBZQ1Q5.tmp.c:5056: by unhandled_exception_handler
7ffff6d88b1c : by ???
RUNTIME ERROR: invalid memory access

What did you expect to see?

Execution without Unhandled Exception error

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.

Copy link

Connected to Huly®: V_0.6-21951

@JalonSolov
Copy link
Contributor

On Linux, it looks almost the same, with just as little indication of the actual error.

[jalon@7950x ~]$ v run main.v
fn (string) []string
fn (string) []string
0x00000000: at ???: RUNTIME ERROR: invalid memory access
/tmp/v_1000/main.01JHZMSVJPWERR1XHF6FMAVRG8.tmp.c:7219: by main
[jalon@7950x ~]$ v -g run main.v
fn (string) []string
fn (string) []string
0x00000000: at ???: RUNTIME ERROR: invalid memory access
/tmp/v_1000/../../../../../../tmp/v_1000/main.01JHZMT483XZJ7D0CS4CPGH634.tmp.c:14068: by main
[jalon@7950x ~]$ 

@JalonSolov JalonSolov added Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. labels Jan 19, 2025
@yuyi98
Copy link
Member

yuyi98 commented Jan 21, 2025

The usage is wrong.

pub struct Tree {
	value string
}
pub type TreeBelt = map[string]fn (input string) []string

fn main() {
	tree := Tree{
		value: 'he he'
	}

	mut belt := TreeBelt({
		"bar" : fn [tree](input string) []string {
			return [tree.value + input]
		}
	})

	mut belt2 := TreeBelt(map[string]fn (string) []string{})
	belt2['bar'] = fn [tree](input string) []string {
		return [tree.value + input]
	}

	// ok
	println(belt["bar"]) // fn (string) []string
	println(belt2["bar"]) // fn (string) []string


	println(belt["bar"]("foo"))
	println(belt2["bar"]("fo")) // ok
}

PS D:\Test\v\tt1> v run .
fn (string) []string
fn (string) []string
['he hefoo']
['he hefo']

@jorgeluismireles
Copy link

The usage is wrong.

Just to clarify for our eyes, I guess you mean, change this:

	mut belt := TreeBelt(map[string]fn (string) []string){
		"bar" : fn [tree](input string) []string {
			return [tree.value + input]
		}
	}

by this:

	mut belt := TreeBelt({
		"bar" : fn [tree](input string) []string {
			return [tree.value + input]
		}
	})

@spytheman
Copy link
Member

why did this parse?

TreeBelt(map[string]fn (string) []string){
        "bar" : fn [tree](input string) []string {

@spytheman
Copy link
Member

oh... it parsed as:

mut belt :=  TreeBelt(    map[string]fn (string) []string     )`

... then followed by (on the same line):

{
        "bar" : fn [tree](input string) []string {
...
}

@spytheman
Copy link
Member

spytheman commented Jan 23, 2025

The compiler just ignores the second map initialization expression (since it was not used for anything), and considers the first one to be a valid cast (but it should not have).

@spytheman
Copy link
Member

I think that mut belt := TreeBelt(map[string]fn (string) []string) should have been a parser error.

@spytheman
Copy link
Member

spytheman commented Jan 23, 2025

A more minimal reproduction is just:

pub type TreeBelt = map[string]fn (input string) []string
mut tb := TreeBelt(   map[string]fn (string) []string   )
println(tb)

which currently produces: TreeBelt({})

@spytheman
Copy link
Member

Simplifying it further:

mut tb := map[string]string
println(tb)

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. Status: Confirmed This bug has been confirmed to be valid by a contributor.
Projects
None yet
Development

No branches or pull requests

5 participants