icexin 最近的时间轴更新
icexin's repos on GitHub
Go · 2312 人关注
eggos
A Go unikernel running on x86 bare metal
Go · 1899 人关注
gocraft
A Minecraft like game written in go
Go · 82 人关注
gocraft-server
gocraft's server https://github.com/icexin/gocraft
Go · 50 人关注
dueros
百度DuerOS的golang实现
Go · 47 人关注
sockhttp
A HTTP&HTTPS proxy over SOCK5
HTML · 30 人关注
eggos-book
The docs of eggos
Go · 30 人关注
sshtun
multiple ssh tunnel at once
Go · 17 人关注
raftkv
A lightweight high available kv-db using raft algorithm
Go · 10 人关注
brpc-go
Go version of brpc baidu_std protocol implementation
Go · 7 人关注
netio
A remote command execution tool without annoying shell escape
Go · 6 人关注
raft-leveldb
leveldb backend for raft
Go · 5 人关注
markdown
markdown parses markdown file and generates html in github style
Go · 4 人关注
clang_complete
A tool generates .clang_complete file for c++ project
C · 4 人关注
fanos
A toy os implemention
Go · 4 人关注
gotun
Simple tunnel using tun/tap
Go · 4 人关注
gowasm
gowasm is a go runtime implemention for WebAssembly generated by go(>=1.11) toolchain.
Go · 3 人关注
mini-falcon
A monitor system implementation for demo only
Go · 3 人关注
rev
Reverse tcp proxy
2 人关注
delve
Delve is a debugger for the Go programming language.
Go · 2 人关注
slides
Some slides
Emacs Lisp · 2 人关注
spacemacs-layers
My personal .spacemacs file and layers for spacemacs https://github.com/syl20bnr/spacemacs
Go · 1 人关注
avro
Package avro implements encoding and decoding of avro objects
1 人关注
brpc
brpc is an Industrial-grade RPC framework using C++ Language, which is often used in high performance system such as Search, Storage, Machine learning, Advertisement, Recommendation etc. "brpc" means "better RPC".
Go · 1 人关注
fdfs
Package fdfs implements fastdfs client in pure go
Go · 1 人关注
gcdemo
a simple mark-and-sweep garbage collection algorithm implementation in golang.
Go · 1 人关注
god
Go · 1 人关注
nes
NES emulator written in Go.
Go · 1 人关注
netiocp
scp for netio https://github.com/icexin/netio
1 人关注
netstack
IPv4 and IPv6 userland network stack
Go · 1 人关注
pcmd
Paralleled command execution tool
Vim script · 1 人关注
rc-files
some rc files
Go · 1 人关注
rssh
remote helping tools
HTML · 0 人关注
blog
The blog site
TypeScript · 0 人关注
ChatGPT-Next-Web
一键拥有你自己的 ChatGPT 网页服务。 One-Click to deploy your own ChatGPT web UI.
Go · 0 人关注
clusterd
Start multiple apps at once when debugging
0 人关注
contract-sdk-go
The Go contract sdk for xuperchain
0 人关注
doc-comments
JavaScript · 0 人关注
docs
documents of xuperchain
Emacs Lisp · 0 人关注
emacs.d
My emacs.d profile forked from https://github.com/purcell/emacs.d
C · 0 人关注
glfw
Go bindings for GLFW 3
Go · 0 人关注
goc
a simple go to c translator
Go · 0 人关注
golib
golib for test
0 人关注
havenask
0 人关注
iavl
Merkleized IAVL+ Tree implementation in Go
Python · 0 人关注
lispy
Automatically exported from code.google.com/p/lispy
Go · 0 人关注
log15
Structured, composable logging for Go
0 人关注
mast
Go immutable, versioned, diffable map implementation of Merkle Search Trees
0 人关注
minidns
simple dns server written in golang
Python · 0 人关注
misc
some small tools
0 人关注
motto
Nodejs module environment in golang(based on otto)
C++ · 0 人关注
muduo
A C++ non-blocking network library for multi-threaded server in Linux
C · 0 人关注
nk
pure go version of nuklear
0 人关注
nucular
GUI toolkit for go
Python · 0 人关注
pdm-cpp
Build python and cpp project using pdm and conan
C++ · 0 人关注
sofa-pbrpc
A light-weight RPC implement of google protobuf RPC framework.
C++ · 0 人关注
thirdparty
Put thirdparty library here for toft ant foxy
Python · 0 人关注
tm
C++ · 0 人关注
toft
C++ Base Library
Python · 0 人关注
tools
Put develop tools here, such as style check and editing
Python · 0 人关注
typhoon-blade
Building system of typhoon cloud computing platform of tencent, support C/C++/protobuf/thrift/lex/yacc/swig.
C++ · 0 人关注
wabt
The WebAssembly Binary Toolkit
0 人关注
wagon
wagon, a WebAssembly-based Go interpreter, for Go.
0 人关注
xuper-java-sdk
The java sdk of xuperunion https://github.com/xuperchain/xuperunion
C++ · 0 人关注
xupercore
0 人关注
xuperos
XuperOS is the open blockchain infrastructure network built on XuperChain
Go · 0 人关注
xuperunion
A highly flexible blockchain architecture with great transaction performance.
WebAssembly · 0 人关注
xvm
The wasm vm for xuperchain
icexin

icexin

V2EX 第 97481 号会员,加入于 2015-02-14 19:43:08 +08:00
将 Go 程序跑在裸机上之 LibOS
  •  3   
    Go 编程语言  •  icexin  •  2021-08-09 11:51:44 AM  •  最后回复来自 wupeaking
    15
    Go 编写的跑在 x86 裸机上的 unikernel
    Go 编程语言  •  icexin  •  2020-10-18 19:14:41 PM  •  最后回复来自 icexin
    22
    go 实现的 Minecraft
  •  2   
    Go 编程语言  •  icexin  •  2018-04-08 01:20:22 AM  •  最后回复来自 zjyl1994
    27
    icexin 最近回复了
    292 天前
    回复了 liyafe1997 创建的主题 程序员 Cursor 到底比 VSCode+Copilot 强在哪?求指导
    copliot 买过年包,个人感觉 cursor 和 copilot 的一个区别是:cursor 可以在代码行中间进行补全,copilot 只能从结尾补全。另外 cursor 的 tab 模式比较智能,准确率很高,小重构的时候框框 tab 就完事了。
    一般是通过 jit 编译到机器码的,具体实现上可以有不经过优化的一遍翻译,也可以有多遍的优化编译。可以参考一下 v8 的 https://v8.dev/blog/liftoff
    2021-11-30 14:50:41 +08:00
    回复了 sunny1688 创建的主题 问与答 关于 golang 碰到的一个问题!
    大家回答的点都集中在内存回收上,实际的问题是没有加锁导致的不变式被打破的问题。

    实际的 slice 包含 data ,len 和 cap 字段,这些大家也都知道了。slice 结构的不变式是:在任意时刻,data 指向的数据长度都是至少是 len 长度,否则访问 len-1 的数据就会 内存错误。

    在题主的代码里面,多个 goroutine 同时对 demo.llist 进行赋值,但因为没有加锁,所以赋值不是原子的,从而会出现一个 goroutine 刚赋值了 data ,还没来得及赋值 data 和 cap 就被其他 goroutine 拿去用了, 破坏了不变式, 从而在扩容的时候就访问了非法内存,从而 panic 。

    一段简单代码就可以复现:


    package main

    import "log"

    type T struct {
    A, B int
    }

    func step(t T) T {
    if t.B != t.A*2 {
    log.Panic(t)
    }
    x := t.A+1
    return T{
    A: x,
    B: 2*x,
    }
    }

    func main() {
    var t = T{
    A: 1,
    B: 2,
    }
    for {
    go func() {
    t = step(t)
    }()
    }
    }
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2169 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 01:04 · PVG 09:04 · LAX 17:04 · JFK 20:04
    ♥ Do have faith in what you're doing.