V: ./vc --help segfaults

Created on 23 Jun 2019  Â·  18Comments  Â·  Source: vlang/v

I've just fetched the latest changes and still crashes when I attempt to run ./vc --help.

To help a bit, here are my specs:

Debian testing 64-bit, fully updated
GCC 8.3.0

Most helpful comment

@stefanos82

I'm sorry, but what? A 25-26 year old kid? He's a grown man who has been accepting hundreds of dollars a month from people for insane claims he has no way of ever achieving. This is bordering on fraudulence.

All 18 comments

Actually it segfaults as a whole...

$ make
wget https://vlang.io/v.c
--2019-06-23 14:08:48--  https://vlang.io/v.c
Resolving vlang.io (vlang.io)... 3.91.188.13
Connecting to vlang.io (vlang.io)|3.91.188.13|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 317523 (310K) [application/octet-stream]
Saving to: ‘v.c’

v.c                 100%[===================>] 310.08K   573KB/s    in 0.5s    

2019-06-23 14:08:50 (573 KB/s) - ‘v.c’ saved [317523/317523]

cc -std=c11 -w -o vc v.c
./vc -o v .
make: *** [Makefile:4: v] Segmentation fault

Can you print GDB output please?

Have you taken a look at the code? This guy doesn't know what he's doing. He barely knows how to program, he clearly knows nothing about compilers or language design, and his language is mostly about copying and pasting C code around. His hello world leaks 3.9 megabytes of memory.

@saevarb can you please stop this? Yes, he's just 25 - 26 years old kid with excessive zeal to achieve something big here, but let's give him time to prove a point.

Give me a moment @medvednikov to do so.

I hope this helps in a way:

Program received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
96  ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.

can you run bt in gdb right after it segfaults?

@stefanos82

I'm sorry, but what? A 25-26 year old kid? He's a grown man who has been accepting hundreds of dollars a month from people for insane claims he has no way of ever achieving. This is bordering on fraudulence.

@medvednikov here you go:

(gdb) bt
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
#1  0x00007ffff7e219ef in _IO_vfprintf_internal (
    s=0x7ffff7f8c760 <_IO_2_1_stdout_>, 
    format=0x5555555839b8 "errno=%d err='%s'\n", ap=ap@entry=0x7fffffffd2b0)
    at vfprintf.c:1638
#2  0x00007ffff7e28606 in __printf (format=<optimized out>) at printf.c:33
#3  0x000055555555c7bc in os.print_c_errno ()
#4  0x000055555555cb28 in os(long, short) ()
#5  0x00005555555679cf in V_v_files_from_dir ()
#6  0x0000555555567f7a in V_add_user_v_files ()
#7  0x0000555555565fce in V_compile ()
#8  0x0000555555565f71 in main ()
V 0.0.12
Use Ctrl-D to exit
For now you have to use println() to print values, this will be fixed soon

>>> println('hello')
[Detaching after vfork from child process 3929]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7e293bf in fgets () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7e293bf in fgets () from /usr/lib/libc.so.6
#1  0x000055555555c7e7 in os__system (cmd=...) at v.c:3862
#2  0x0000555555568479 in V_cc (c=0x555555595630) at v.c:7061
#3  0x0000555555567b7a in V_compile (c=0x555555595630) at v.c:6904
#4  0x000055555556a88d in run_repl () at v.c:7614
#5  0x0000555555566cc7 in main (argc=1, argv=0x7fffffffd898) at v.c:6590

you need to compile v.c using:
gcc -lgcc_s -w -o vc v.c

Still segfaults like crazy...

I think the reason behind this segfault relates to #457 .

I cloned the repo in a folder of my choice, because $HOME/code/ is where I have all my local projects, in mutliple subfolders for each language separately.

@medvednikov can you verify this please so we can close this ticket in case this is the actual reason behind this behavior?

yes, Still segfaults, but no segfaults when runing:
./vc -o v .
and can use:
./v --help

I'm sorry about it.

maybe it can help #464

I think two fixes is needed.

first, fix v.c to handle --help option properly.
currently, v.c treat it as a filepath. so compiler lookups file that has path "--help".

second, add #include <string.h> to v.c.
it seems to causes a segfault if call print strerror without include it.
https://stackoverflow.com/questions/17174081/why-cant-the-result-of-strerror-be-returned

use -std=gnu11 instead

OS: Ubuntu18.04/ WSL Ubuntu18.04
gcc: 7.4.0

I encountered this problem both in Ubuntu18.04 and WSL. I solved it by modifing line 7 in the file Makefile to
gcc -std=c++11 -w -o vc v.c

and add #include<string.h> to v.c

But it just work in WSL, not in Ubuntu18.04

Fixed by v0.1.0 probably, can you test and try again>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jtkirkpatrick picture jtkirkpatrick  Â·  3Comments

elimisteve picture elimisteve  Â·  3Comments

penguindark picture penguindark  Â·  3Comments

aurora picture aurora  Â·  3Comments

shouji-kazuo picture shouji-kazuo  Â·  3Comments