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

segfault in auto string method generated for []&int{len:1} (does not check for 0 pointers) #14786

Closed
spytheman opened this issue Jun 19, 2022 · 1 comment · Fixed by #14829
Closed
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@spytheman
Copy link
Member

V doctor:

OS: linux, Ubuntu 20.04.3 LTS
Processor: 2 cpus, 64bit, little endian, Intel(R) Core(TM) i3-3225 CPU @ 3.30GHz
CC version: cc (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0

getwd: /v/cleanv
vmodules: /home/delian/.vmodules
vroot: /v/cleanv
vexe: /v/cleanv/v
vexe mtime: 2022-06-19 06:36:55
is vroot writable: true
is vmodules writable: true
V full version: V 0.2.4 1d46213.e031096

Git version: git version 2.25.1
Git vroot status: weekly.2022.24-27-ge0310964
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 eee03626

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

fn main() {
	a := []&int{len: 1}
	println(a)
}

What did you expect to see?

[ nil ] or some other representation of an array containing 1 zero pointer ([&0] would be ambigous though with an element pointing to an actual int 0 value)

What did you see instead?

signal 11: segmentation fault
/tmp/v_1000/auto_str_method_not_checking_for_null_pointers.3793111048561402845.tmp.c:7070: at print_backtrace: Backtrace
/tmp/v_1000/auto_str_method_not_checking_for_null_pointers.3793111048561402845.tmp.c:7141: by v_segmentation_fault_handler
7ffff7dcc0c0 : by ???
/tmp/v_1000/auto_str_method_not_checking_for_null_pointers.3793111048561402845.tmp.c:2014: by Array_int_ptr_str
/tmp/v_1000/auto_str_method_not_checking_for_null_pointers.3793111048561402845.tmp.c:12079: by main__main
/tmp/v_1000/auto_str_method_not_checking_for_null_pointers.3793111048561402845.tmp.c:12449: by main
@spytheman spytheman added the Bug This tag is applied to issues which reports bugs. label Jun 19, 2022
@spytheman spytheman self-assigned this Jun 19, 2022
@medvednikov
Copy link
Member

Just like with struct inits requiring reference initialization, we should require such arrays to contain valid references (unless in unsafe).

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants