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

./vc --help segfaults #438

Closed
stefanos82 opened this issue Jun 23, 2019 · 18 comments
Closed

./vc --help segfaults #438

stefanos82 opened this issue Jun 23, 2019 · 18 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@stefanos82
Copy link

stefanos82 commented Jun 23, 2019

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
@stefanos82
Copy link
Author

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

@medvednikov
Copy link
Member

Can you print GDB output please?

@saevarb
Copy link

saevarb commented Jun 23, 2019

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.

@stefanos82
Copy link
Author

@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.

@stefanos82
Copy link
Author

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.

@medvednikov
Copy link
Member

can you run bt in gdb right after it segfaults?

@saevarb
Copy link

saevarb commented Jun 23, 2019

@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.

@stefanos82
Copy link
Author

@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 ()

@shaoxie1986
Copy link

shaoxie1986 commented Jun 23, 2019

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

@shaoxie1986
Copy link

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

@stefanos82
Copy link
Author

Still segfaults like crazy...

@stefanos82
Copy link
Author

stefanos82 commented Jun 23, 2019

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?

@oxy oxy added the segfault label Jun 23, 2019
@shaoxie1986
Copy link

shaoxie1986 commented Jun 23, 2019

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

I'm sorry about it.

@shaoxie1986
Copy link

shaoxie1986 commented Jun 23, 2019

maybe it can help #464

@musou1500
Copy link
Member

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

@whoizit
Copy link
Contributor

whoizit commented Jun 23, 2019

use -std=gnu11 instead

@ouening
Copy link

ouening commented Jun 24, 2019

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

@oxy
Copy link

oxy commented Jun 24, 2019

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

@oxy oxy closed this as completed Jun 24, 2019
@medvednikov medvednikov added the Bug This tag is applied to issues which reports bugs. label Jul 19, 2022
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

8 participants