Giter VIP home page Giter VIP logo

gin-inject's Introduction

Hi, I'm E99p1ant. 👋

Some cool gadgets I made:

  • 🚩 Cardinal - CTF AWD platform / ★882 / Go GORM Vue Server-Sent Events CRUD
  • 💓 mebeats - Real-time MiBand heart rate data collection / ★235 / Go Bluetooh Low Energy Flamego Image generation
  • 🔮 Elaina - Docker-based remote code runner / ★46 / Go Vue Docker Rate Limit CodeMirror
  • 🧹 Houki - Customizable MitM proxy / ★34 / Go MitM HTTP(S) Flamego alpine.js SQLite
  • ☁️ Raika - Hybrid cloud serverless function framework / ★6 / Go Flamego Serverless CLI Daemon
  • 📫 NekoBox - Anonymous question box / ★196 / Go GORM Flamego Uptrace CRUD reCaptcha
  • 😵 ingress-custom-error-pages - Customized Ingress error pages / ★6 / Go Flamego Kubernetes Nginx Ingress
  • 🪤 k8s-image-replacer - Replace image when creating pod, aims to speed up image pulling / ★6 / Go Flamego Kubernetes Mutating Webhook
  • 🚜 forklift - Lightweight container image pre-download component for Kubernetes / ★6 / Go Kubernetes Helm Chart
  • 👻 icppp - The way to bypass website ICP checking / ★68 / Go docker-compose
  • 👾 Apicon - API sharing platform / Go beego GORM Redis Serverless API Gateway Rate Limit
  • 💫 Asteroid - CTF AWD real-time 3D data visualization / ★133 / C# Unity3D WebSocket
  • 🔧 jkit - CLI tool for JSON / ★5 / Go JSON
  • 🔗 Frlink - Beautify WordPress friends links / ★8 / PHP WordPress
  • 🔍 GrabMe - Hide contents in your WordPress posts / ★4 / PHP WordPress

🎯 My CVE list:

visitors

gin-inject's People

Watchers

 avatar  avatar  avatar

Forkers

ismart-yuxi

gin-inject's Issues

panic on concurrent condition

问题

这个项目的依赖容器基于go-macaron/inject,内部实现是map

type injector struct {
	values map[reflect.Type]reflect.Value
	parent Injector
}

依赖注入调用的是injectorMap方法

func (i *injector) Map(val interface{}) TypeMapper {
	i.values[reflect.TypeOf(val)] = reflect.ValueOf(val)
	return i
}

但是,Go的原生map不支持并发写,所以在并发状态下,会报错

if h.flags&hashWriting != 0 { //位置:runtime/map.go line:585 on Go 1.15.4
		throw("concurrent map writes")
}

尝试对写map的部分加锁

sMapLock.Lock() 
		inj.Map(c)
		inj.Map(ginsession.FromContext(c))
		for _, dep := range deps {
			inj.Map(dep)
		}
sMapLock.Unlock()

但是在handler内部报错runtime error: invalid memory address or nil pointer dereference

问题是注入进去的gin.Contextnil,估计还是并发写的锅

修复

因为go-macaron/inject实际只有一个文件,能不能复制出来采用sync.Map实现

Make Gin Great Again!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.