Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x50631bb] #1

Open
rcrick opened this issue Jun 15, 2022 · 1 comment

Comments

@rcrick
Copy link

rcrick commented Jun 15, 2022

Hi @MordFustang21 I'm developing a qrcode detect api, when I do stress test, some time the it will panic at two line
one is panic at s := C.zbar_image_first_symbol(i.image),
the other one is at below

func (s *Symbol) Each(f func(string)) {
	t := s
       // some time t is nil
	for {
		f(t.Data())

		t = t.Next()

		if t == nil {
			break
		}
	}
}

here is my test code

package main

import (
	"bytes"
	"fmt"
	"github.com/MordFustang21/gozbar"
	"image"
	_ "image/gif"
	_ "image/jpeg"
	_ "image/png"
	"io/ioutil"
	"sync"
)

func main() {
	var wg sync.WaitGroup
	wg.Add(2000)
	for i :=0; i < 2000; i++ {
		go func() {
			defer wg.Done()
			b, err := ioutil.ReadFile("img.png")
			if err != nil {
				panic(err)
			}
			img, _, err := image.Decode(bytes.NewReader(b))
			if err != nil {
				panic(err)
			}

			barcodeImg := gozbar.FromImage(img)
			scanner := gozbar.NewScanner()
			scanner.SetConfig(gozbar.NONE, gozbar.CFG_ENABLE, 1)

			err = scanner.Scan(barcodeImg)
			if err != nil {
				panic(err)
			}

			defer scanner.Destroy()
	
			barcodeImg.First().Each(func(str string) {
				fmt.Println(str)
			})

		}()
	}
	wg.Wait()

}

here is the image
image

Do you have any suggestion?

@MordFustang21
Copy link
Owner

Sorry for the late reply and I'm sure you've already found an alternative solution. I forked this from another library and haven't really looked super closely at how this would work in multiple goroutines. My guess is there's likely a race condition in there that needs to be addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants