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

Data race on mqicb/cbMap #148

Closed
ravellan opened this issue Aug 26, 2020 · 2 comments
Closed

Data race on mqicb/cbMap #148

ravellan opened this issue Aug 26, 2020 · 2 comments

Comments

@ravellan
Copy link

It is not unlikely to use callback related verbs from multiple go routines, and since cbMap is global in the package and concurrent map access can be unsafe, perhaps it should be protected by a mutex?
POC code:

package main

import (
        "github.com/ibm-messaging/mq-golang/v5/ibmmq"
)

func main() {
        for i := 0; i < 5; i++ {
                go func() {
                        qMgr, err := ibmmq.Conn("")
                        if err != nil {
                                panic(err)
                        }
                        od := ibmmq.NewMQOD()
                        od.ObjectName = "SYSTEM.DEFAULT.MODEL.QUEUE"
                        od.ObjectType = ibmmq.MQOT_Q
                        q, _ := qMgr.Open(od, ibmmq.MQOO_INPUT_SHARED)
                        cbd := ibmmq.NewMQCBD()
                        cbd.CallbackFunction = func(a *ibmmq.MQQueueManager,
                                b *ibmmq.MQObject, c *ibmmq.MQMD, d *ibmmq.MQGMO,
                                e []byte, f *ibmmq.MQCBC, g *ibmmq.MQReturn) {
                        }
                        q.CB(ibmmq.MQOP_REGISTER, cbd, ibmmq.NewMQMD(), ibmmq.NewMQGMO())
                        qMgr.Ctl(ibmmq.MQOP_START, ibmmq.NewMQCTLO())
                        qMgr.Ctl(ibmmq.MQOP_STOP, ibmmq.NewMQCTLO())
                        q.Close(0)
                        qMgr.Disc()
                }()
        }
}

>go run -race .
==================
WARNING: DATA RACE
@ibmmqmet
Copy link
Collaborator

ibmmqmet commented Sep 3, 2020

Thanks for finding that. I'll get an update for it soon.

ibmmqmet added a commit that referenced this issue Sep 10, 2020
Add tracing for mqmetric functions
Add a mutex around callback controller (#148)

Verify qdepth for CHSTATUS operations
@ibmmqmet
Copy link
Collaborator

Fixed in current level

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