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

icexin

V2EX member #97481, joined on 2015-02-14 19:43:08 +08:00
icexin's recent replies
copliot 买过年包,个人感觉 cursor 和 copilot 的一个区别是:cursor 可以在代码行中间进行补全,copilot 只能从结尾补全。另外 cursor 的 tab 模式比较智能,准确率很高,小重构的时候框框 tab 就完事了。
一般是通过 jit 编译到机器码的,具体实现上可以有不经过优化的一遍翻译,也可以有多遍的优化编译。可以参考一下 v8 的 https://v8.dev/blog/liftoff
Nov 30, 2021
Replied to a topic by 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)
}()
}
}
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5781 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 32ms · UTC 02:19 · PVG 10:19 · LAX 19:19 · JFK 22:19
♥ Do have faith in what you're doing.