otiai10 / gosseract

Go package for OCR (Optical Character Recognition), by using Tesseract C++ library
https://pkg.go.dev/github.com/otiai10/gosseract
MIT License
2.74k stars 290 forks source link

Сrashes with concurrency (win11) #307

Closed biter777 closed 7 months ago

biter777 commented 8 months ago

Сrashes with concurrency

var wg sync.WaitGroup
func main() {
    sem := make(chan struct{})
    for i := 0; i < 100; i++ {
        wg.Add(1)
        go test(sem, i)
    }
    close(sem)
    wg.Wait()
}

func test(sem chan struct{}, threadNum int) error {
        defer wg.Done()
    <-sem

    client := gosseract.NewClient()
    defer client.Close()
    err := client.SetTessdataPrefix("C:\\Program Files\\Tesseract-OCR\\tessdata")
    if err != nil {
        return err
    }

    err = client.SetImage("filename")
    if err != nil {
        return err
    }
    text, err = client.Text()
    if err != nil {
        return err
    }
    fmt.Println(text, threadNum)
    return nil
}
win11 
Version 10.0.22621.3296
go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\biter.DESKTOP-APJ7MVH\AppData\Local\go-build
set GOENV=C:\Users\biter.DESKTOP-APJ7MVH\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Programming\Go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Programming\Go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Programming\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Programming\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.19.4
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\BITER~1.DES\AppData\Local\Temp\go-build1626473980=/tmp/go-build -gno-record-gcc-switches
go version go1.19.4 windows/amd64
tesseract --version
tesseract 5.3.4
 leptonica-1.84.2
  libgif 5.2.1 : libjpeg 8d (libjpeg-turbo 2.1.4) : libpng 1.6.38 : libtiff 4.4.0 : zlib 1.2.13 : libwebp 1.2.4 : libopenjp2 2.5.0
 Found AVX2
 Found AVX
 Found FMA
 Found SSE4.1
 Found OpenMP 201511
otiai10 commented 8 months ago

Please describe crash logs

biter777 commented 8 months ago

No logs in go, just close, without trace