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

runtime error, while printing println(invalid.str()), where invalid is ?&html.Tag #23558

Closed
spytheman opened this issue Jan 23, 2025 · 2 comments · Fixed by #23563
Closed

runtime error, while printing println(invalid.str()), where invalid is ?&html.Tag #23558

spytheman opened this issue Jan 23, 2025 · 2 comments · Fixed by #23563
Assignees
Labels
Auto str Method Generation Bugs/feature requests, that are related to the automatic string method generation. Bug This tag is applied to issues which reports bugs. Option Type Bugs/feature requests, that are related to `?Type`. Unit: Checker Bugs/feature requests, that are related to the type checker. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.

Comments

@spytheman
Copy link
Member

spytheman commented Jan 23, 2025

V version: V 0.4.9 ee66c72, press to see full `v doctor` output
V full version V 0.4.9 bd10e12.ee66c72
OS linux, Ubuntu 20.04.6 LTS
Processor 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-3225 CPU @ 3.30GHz
Memory 3.55GB/15.05GB
V executable /home/delian/code/v/v
V last modified time 2025-01-23 10:23:44
V home dir OK, value: /home/delian/code/v
VMODULES OK, value: /home/delian/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/delian/code/v
Git version git version 2.47.1
V git status weekly.2025.03-26-gee66c72a (1 commit(s) behind V master)
.git/config present true
cc version cc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0
gcc version gcc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0
clang version clang version 10.0.0-4ubuntu1
tcc version tcc version 0.9.28rc 2024-07-31 HEAD@1cee0908 (x86_64 Linux)
tcc git status thirdparty-linux-amd64 0134e9b9
emcc version N/A
glibc version ldd (Ubuntu GLIBC 2.31-0ubuntu9.16) 2.31

What did you do?
./v -g -o vdbg cmd/v && ./vdbg bug2.v && bug2

module main

import net.html

fn main() {
	mut doc := html.parse('<body><div class="Box-footer"><div class="Truncate">abc</div></div></body>')
	footer := doc.get_tags_by_class_name('Box-footer')[0]
	invalid := footer.get_tag_by_class_name('invalid')
	println(invalid.str()) // runtime error, invalid memory access
}

What did you see?

/tmp/v_1000/bug2.01JJ9CCBMN2ZRS3H58JWCDV47T.tmp.c:8734: at net__html__Tag_str: RUNTIME ERROR: invalid memory access
/tmp/v_1000/bug2.01JJ9CCBMN2ZRS3H58JWCDV47T.tmp.c:8827: by main__main
/tmp/v_1000/bug2.01JJ9CCBMN2ZRS3H58JWCDV47T.tmp.c:8854: by main

What did you expect to see?

a printed value, without a stacktrace

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.

@spytheman spytheman added Auto str Method Generation Bugs/feature requests, that are related to the automatic string method generation. Bug This tag is applied to issues which reports bugs. Option Type Bugs/feature requests, that are related to `?Type`. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. labels Jan 23, 2025
Copy link

Connected to Huly®: V_0.6-21986

@spytheman
Copy link
Member Author

This should have a checker error for the use of invalid.str(), i.e. it should require invalid?str() or equivalent instead.

@felipensp felipensp self-assigned this Jan 23, 2025
@felipensp felipensp added the Unit: Checker Bugs/feature requests, that are related to the type checker. label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto str Method Generation Bugs/feature requests, that are related to the automatic string method generation. Bug This tag is applied to issues which reports bugs. Option Type Bugs/feature requests, that are related to `?Type`. Unit: Checker Bugs/feature requests, that are related to the type checker. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants