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

V run / REPL fails with "signal 11: segmentation fault" for basic examples/hello_world.v program #20170

Closed
rmgas1 opened this issue Dec 14, 2023 · 4 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@rmgas1
Copy link

rmgas1 commented Dec 14, 2023

Describe the bug

Basic program fails with "signal 11: segmentation fault" when executed via 'v run' or via 'REPL'.

Quickest way to reproduce it is to call print* functions, e.g.: examples/hello_world.v

It looks like it is attempting to write to memory that has not been allocated to the process for writing (for example, when array bounds are exceeded).

1. Update V et al:

$> v up
Updating V...
V is already updated.
Current V version: V 0.4.3 0b12d64, timestamp: 2023-12-13 22:32:52 +0200
$> v outdated
Modules are up to date.
$> v install
Detected v.mod file inside the project directory. Using it...
Nothing to install.
$> 

2. Segmentation fault on 'v run examples/hello_world.v':

$>  ls examples/hello_world*
examples/hello_world.v
$>  cat examples/hello_world.v
println('Hello, World!')
$>  v run examples/hello_world.v
signal 11: segmentation fault
0   libsystem_platform.dylib            0x00007ff8081085ed _sigtramp + 29
1   ???                                 0x0000000000000000 0x0 + 0
2   v                                   0x000000010c25251b os__Process__spawn + 155
3   v                                   0x000000010c252443 os__Process_wait + 35
4   v                                   0x000000010c580d85 v__builder__Builder_run_compiled_executable_and_exit + 3701
5   v                                   0x000000010c57e55c v__builder__compile + 124
6   v                                   0x000000010c589ff9 main__rebuild + 121
7   v                                   0x000000010c589205 main__main + 2181
8   v                                   0x000000010c58eb10 main + 64
9   dyld                                0x00007ff807d8141f start + 1903
$>

3. Compiled version works:

$> ls examples/hello_world*
examples/hello_world*   examples/hello_world.v
$>  ./examples/hello_world
Hello, World!
$>

4. Segmentation fault on REPL equivalent:

$> v
 ____    ____
 \   \  /   /  |  Welcome to the V REPL (for help with V itself, type  exit , then run  v help ).
  \   \/   /   |  Note: the REPL is highly experimental. For best V experience, use a text editor,
   \      /    |  save your code in a  main.v  file and execute:  v run main.v
    \    /     |  V 0.4.3 0b12d64 . Use  list  to see the accumulated program so far.
     \__/      |  Use Ctrl-C or  exit  to exit, or  help  to see other available commands.

>>> print('test')
signal 11: segmentation fault
0   libsystem_platform.dylib            0x00007ff8081085ed _sigtramp + 29
1   ???                                 0x0000000000000000 0x0 + 0
2   v                                   0x000000010ab1151b os__Process__spawn + 155
3   v                                   0x000000010ab11443 os__Process_wait + 35
4   v                                   0x000000010ae3fd85 v__builder__Builder_run_compiled_executable_and_exit + 3701
5   v                                   0x000000010ae3d55c v__builder__compile + 124
6   v                                   0x000000010ae48ff9 main__rebuild + 121
7   v                                   0x000000010ae48205 main__main + 2181
8   v                                   0x000000010ae4db10 main + 64
9   dyld                                0x00007ff807d8141f start + 1903
>>> println('test')
signal 11: segmentation fault
0   libsystem_platform.dylib            0x00007ff8081085ed _sigtramp + 29
1   ???                                 0x0000000000000000 0x0 + 0
2   v                                   0x00000001016bd51b os__Process__spawn + 155
3   v                                   0x00000001016bd443 os__Process_wait + 35
4   v                                   0x00000001019ebd85 v__builder__Builder_run_compiled_executable_and_exit + 3701
5   v                                   0x00000001019e955c v__builder__compile + 124
6   v                                   0x00000001019f4ff9 main__rebuild + 121
7   v                                   0x00000001019f4205 main__main + 2181
8   v                                   0x00000001019f9b10 main + 64
9   dyld                                0x00007ff807d8141f start + 1903
>>> exit
$> 

Reproduction Steps

Run the following In V directory:

v up
v outdated
v install
ls examples/hello_world*
cat examples/hello_world.v
v run examples/hello_world.v
ls examples/hello_world*
./examples/hello_world

In v REPL:

print('test')
println('test')

Expected Behavior

Expected v run to execute code without an error.
Expected v REPL to execute code without an error.

Current Behavior

Segmentation fault in both cases.

Possible Solution

No response

Additional Information/Context

No response

V version

Current V version: V 0.4.3 0b12d64, timestamp: 2023-12-13 22:32:52 +0200

Environment details (OS name and version, etc.)

$> v doctor
V full version: V 0.4.3 0b12d64
OS: macos, macOS, 13.5.2, 22G91
Processor: 16 cpus, 64bit, little endian, Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz

getwd: /Users/USER/PATH/v/v
vexe: /Users/USER/PATH/v/v/v
vexe mtime: 2023-12-14 00:57:32

vroot: OK, value: /Users/USER/PATH/v/v
VMODULES: OK, value: /Users/USER/.vmodules
VTMP: OK, value: /tmp/v_502

Git version: git version 2.43.0
Git vroot status: weekly.2023.50-22-g0b12d647-dirty
.git/config present: true

CC version: Apple clang version 15.0.0 (clang-1500.1.0.2.5)
thirdparty/tcc status: thirdparty-macos-amd64 46662e20
$>

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.

@rmgas1 rmgas1 added the Bug This tag is applied to issues which reports bugs. label Dec 14, 2023
@JalonSolov
Copy link
Contributor

Try export VFLAGS='-use-os-system-to-run' then try the v run command again.

@rmgas1
Copy link
Author

rmgas1 commented Dec 14, 2023

Try export VFLAGS='-use-os-system-to-run' then try the v run command again.

Yes. This setting does address this issue, and both 'v run' and REPL work ok.

Is there a way make this the default setting for v on MacOS (outside of setting it in the user's profile)?

@shove70
Copy link
Contributor

shove70 commented Dec 14, 2023

Try export VFLAGS='-use-os-system-to-run' then try the v run command again.

Yes. This setting does address this issue, and both 'v run' and REPL work ok.

Is there a way make this the default setting for v on MacOS (outside of setting it in the user's profile)?

Refer to:
#19384

@rmgas1
Copy link
Author

rmgas1 commented Dec 14, 2023

Refer to: #19384

Thanks for your help. No permanent solution yet, but as it is being managed under that issue, I'll close this one.

@rmgas1 rmgas1 closed this as completed Dec 14, 2023
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

3 participants