Comments (4)
unrelated: in the definition of read_any, line 70, shouldn't it be
new_read := r.read(mut b[read..]) or { 0 }
instead of
... or { return error('none') }
?
from v.
For me, passing -cflags -fno-inline-small-functions
fixes the segfault, when the program was compiled using gcc:
#0 14:02:53 ᛋ master /v/oo❱v -cc gcc -prod run z.v
signal 11: segmentation fault
| 0x5555555673c1 | /space/v/oo/z(+0x133c1)
| 0x55555556a3e0 | /space/v/oo/z(+0x163e0)
| 0x55555556a718 | /space/v/oo/z(+0x16718)
| 0x555555556b94 | /space/v/oo/z(+0x2b94)
| 0x155555302083 | /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)
| 0x555555556c4e | /space/v/oo/z(+0x2c4e)
#139 14:03:05 ᛋ master /v/oo❱v -cflags -fno-inline-small-functions -cc gcc -prod run z.v
#0 14:03:19 ᛋ master /v/oo❱
Using -cc clang
also works, so I think it is gcc optimization specific.
from v.
This also can serve as a workaround:
#0 14:07:25 ᛋ master /v/oo❱git diff
diff --git vlib/os/file.c.v vlib/os/file.c.v
index cb3d1e235..6108974fe 100644
--- vlib/os/file.c.v
+++ vlib/os/file.c.v
@@ -47,6 +47,7 @@ fn fix_windows_path(path string) string {
}
// open_file tries to open or create a file with custom flags and permissions.
+@[noinline]
pub fn open_file(path string, mode string, options ...int) !File {
mut flags := 0
mut seek_to_end := false
#0 14:07:27 ᛋ master /v/oo❱
#0 14:07:56 ᛋ master /v/oo❱
#0 14:07:56 ᛋ master /v/oo❱v -cc gcc -prod run x.v
os.File{
cfile: 5555555ba2a0
fd: 3
is_opened: true
}
module main
import os
import io
fn main() {
mut file := os.open_file(@FILE, 'r')!
println(file)
mut buff_reader := io.new_buffered_reader(reader: file)
for {
a := buff_reader.read_line() or { break }
println(a)
}
println('done')
}
done
#0 14:08:03 ᛋ master /v/oo❱git stash
Saved working directory and index state WIP on master: 6f4d9aecf x.json2: minor performance improvement, update benchmark recommendations (#20954)
#0 14:08:12 ᛋ master /v/oo❱v -cc gcc -prod run x.v
os.File{
cfile: 0
fd: 0
is_opened: false
}
signal 11: segmentation fault
| 0x555555567471 | /space/v/oo/x(+0x13471)
| 0x555555569163 | /space/v/oo/x(+0x15163)
| 0x555555556b94 | /space/v/oo/x(+0x2b94)
| 0x155555302083 | /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)
| 0x555555556c4e | /space/v/oo/x(+0x2c4e)
#139 14:08:20 ᛋ master /v/oo❱
from v.
I've also tried adding @[noinline]
tags to new_buffered_reader
and read_line
, but those do not affect the outcome, only tagging open_file
does.
from v.
Related Issues (20)
- Bignum operations should be optimized HOT 7
- coroutines memory usage HOT 4
- Uniform Function Call Syntax (UFCS) HOT 2
- Veb livereload flag needs to be renamed HOT 1
- A compilation error is thrown after compiling the Custom Iterators example in the For Loop documentation HOT 3
- Compiling an Array Slice example does not produce the result mentioned in the documentaion
- Struct and Reference Struct type mismatch in Struct Default Value
- auto deref not working
- rename os.getwd -> os.getcwd HOT 1
- cgen: regression for Option return of C alias
- Rename 'make.bat' to another name
- Sibling Module Imports
- Generic function pointer returns wrong output HOT 2
- @[heap] flag in wrapper struct does not make the error disappear
- using a C struct as a struct field does not adopted default values HOT 1
- v does not support Chinese character path name under Windows 10 HOT 3
- Storing a function result value in a variable does not work as expected in an `or` block
- A struct with an option field of type interface doesn't accept none as value
- cgen error for `x := 5 * p` where `p` is &int HOT 2
- [info] and incase helps others (is now working) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v.