Open samjtro opened 2 years ago
We are currently having concurrency issues. I don't entirely know why this is happening, given that nothing should realistically be broken. The function in which the issue is occurring is MACD()
. This should also be of note for issue #2.
Error message as follows:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x1 addr=0x0 pc=0x3cd2c2]
goroutine 26 [running]:
sync.(*WaitGroup).state(...)
C:/Program Files/Go/src/sync/waitgroup.go:40
sync.(*WaitGroup).Add(0x0?, 0x0?)
C:/Program Files/Go/src/sync/waitgroup.go:63 +0x22
main.DataSlice.MACD({0xc000296000, 0x40, 0x0?}, 0x0?)
C:/Users/samue/Workspace/Proj/go-algotrader/main.go:246 +0x7c
created by main.DataSlice.Set
C:/Users/samue/Workspace/Proj/go-algotrader/utils.go:37 +0x2b0
exit status 2
The code for MACD()
looks like this:
func (d DataSlice) MACD(wg *sync.WaitGroup) {
var wg1 *sync.WaitGroup
defer wg.Done()
wg1.Add(1)
defer wg1.Done()
m6.Lock()
d2 := make(DataSlice, len(d))
copy(d, d2)
go d2.EMA(26, wg1)
for i, x := range d {
for _, y := range d2 {
macd := x.EMA - y.EMA
d[i].MACD = macd
}
}
m6.Unlock()
}
Any thoughts are welcome!
We are currently having concurrency issues. I don't entirely know why this is happening, given that nothing should realistically be broken. The function in which the issue is occurring is
MACD()
. This should also be of note for issue #2.Error message as follows:
panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x1 addr=0x0 pc=0x3cd2c2] goroutine 26 [running]: sync.(*WaitGroup).state(...) C:/Program Files/Go/src/sync/waitgroup.go:40 sync.(*WaitGroup).Add(0x0?, 0x0?) C:/Program Files/Go/src/sync/waitgroup.go:63 +0x22 main.DataSlice.MACD({0xc000296000, 0x40, 0x0?}, 0x0?) C:/Users/samue/Workspace/Proj/go-algotrader/main.go:246 +0x7c created by main.DataSlice.Set C:/Users/samue/Workspace/Proj/go-algotrader/utils.go:37 +0x2b0 exit status 2
The code for
MACD()
looks like this:func (d DataSlice) MACD(wg *sync.WaitGroup) { var wg1 *sync.WaitGroup defer wg.Done() wg1.Add(1) defer wg1.Done() m6.Lock() d2 := make(DataSlice, len(d)) copy(d, d2) go d2.EMA(26, wg1) for i, x := range d { for _, y := range d2 { macd := x.EMA - y.EMA d[i].MACD = macd } } m6.Unlock() }
Any thoughts are welcome!
Concurrency issues solved by: a56119a6934e6e79d14c181ece095c6bb92f35fa
This will just be a long running thread dealing with the three topics in the title.