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

Incorrect Auto De-referencing of &net.TcpConn in Map Access #21067

Open
M1ndo opened this issue Mar 20, 2024 · 0 comments
Open

Incorrect Auto De-referencing of &net.TcpConn in Map Access #21067

M1ndo opened this issue Mar 20, 2024 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@M1ndo
Copy link

M1ndo commented Mar 20, 2024

Describe the bug

Incorrect handling of pointers within maps, when attempting to access a map that contains nested maps, where the innermost map's values are pointers to net.TcpConn objects.
image

Reproduction Steps

Create a map with a string key and a value that is another map, where the inner map's values are reference to net.TcpConn objects (eg) con_list map[string]map[string]&net.TcpConn.
Attempt to access an element in the inner map.
Observe that the returned value is a pointer to the reference net.TcpConn object, not a reference.

Full source code: transport/transport.v https://0x0.st/Xr_o.v
main.v https://0x0.st/XrzL.v

Expected Behavior

Accessing an element in the inner map should return a reference to the net.TcpConn object (&net.TcpConn).

Current Behavior

A pointer to the net.TcpConn object is returned instead of a reference. (&&net.TcpConn)

Possible Solution

A possible workaround would be to create a mutable copy of reference.

for _, connection in unsafe {conx.con_list[id]} {
   mut actual_connection := unsafe {connection}

Additional Information/Context

No response

V version

V 0.4.4 44c78ed

Environment details (OS name and version, etc.)

V full version: V 0.4.4 298a2a2.44c78ed
OS: linux, "Arch Linux"
Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i5 CPU 1155G7 @ 2.50GHz

getwd: /home/alienx/Projects/Git_Pro/V_Projects/testing/testing/multi_conx/src
vexe: /home/alienx/Public/v/v
vexe mtime: 2024-03-20 01:46:39

vroot: OK, value: /home/alienx/Public/v
VMODULES: OK, value: /home/alienx/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.44.0
Git vroot status: weekly.2024.12-5-g44c78ed7
.git/config present: true

CC version: cc (GCC) 13.2.1 20230801
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.

@M1ndo M1ndo added the Bug This tag is applied to issues which reports bugs. label Mar 20, 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.
Projects
None yet
Development

No branches or pull requests

1 participant