lpc921 / telegraf-execd-opcda

External input plugin for telegraf to gather data from OPC DA
MIT License
7 stars 2 forks source link

panic: runtime error: invalid memory address or nil pointer dereference #1

Closed GigaVik closed 1 month ago

GigaVik commented 6 months ago

Hallo! Windows Server 2008 R2 Standart SP1 64x conf:

[[inputs.opcda]]
  # Measurement name
  name = "data"

  # OPC DA server
  server = "Progress.OpenOPC.2"

  # First successful node in the list is used
  nodes = ["localhost"]

  # Node ID configuration
  # item        - OPC DA Item Name or ItemID
  # name        - field name to use in the output (optional)
  # tags        - extra tags to be added to the output metric (optional)
  # Example:

  items = [
    { item = "opc.point.38799", name = "38799" }    
  ]

error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x5076e6]

goroutine 1 [running]:
github.com/go-ole/go-ole.(*IDispatch).VTable(...)
        C:/Users/BILLP/go/pkg/mod/github.com/go-ole/go-ole@v1.2.4/idispatch.go:18
github.com/go-ole/go-ole.getIDsOfName(0x0, {0x13651d7c, 0x1, 0x1})
        C:/Users/BILLP/go/pkg/mod/github.com/go-ole/go-ole@v1.2.4/idispatch_windows.go:20 +0xc6
github.com/go-ole/go-ole.(*IDispatch).GetIDsOfName(...)
        C:/Users/BILLP/go/pkg/mod/github.com/go-ole/go-ole@v1.2.4/idispatch.go:22
github.com/go-ole/go-ole.(*IDispatch).GetSingleIDOfName(0x0, {0xabfc7c, 0x7})
        C:/Users/BILLP/go/pkg/mod/github.com/go-ole/go-ole@v1.2.4/idispatch.go:47 +0x5d
github.com/go-ole/go-ole.(*IDispatch).InvokeWithOptionalArgs(0x0, {0xabfc7c, 0x7}, 0x1, {0x13651e04, 0x2, 0x2})
        C:/Users/BILLP/go/pkg/mod/github.com/go-ole/go-ole@v1.2.4/idispatch.go:63 +0x35
github.com/go-ole/go-ole/oleutil.CallMethod(...)
        C:/Users/BILLP/go/pkg/mod/github.com/go-ole/go-ole@v1.2.4/oleutil/oleutil.go:51
github.com/konimarti/opc.(*AutomationObject).Connect(0x1348e118, {0x13423410, 0x12}, {0x1377ec10, 0x9})
        C:/Users/BILLP/go/pkg/mod/github.com/konimarti/opc@v0.3.1/connection_windows.go:126 +0x218
github.com/konimarti/opc.(*AutomationObject).TryConnect(0x1348e118, {0x13423410, 0x12}, {0x137d6238, 0x1, 0x1})
        C:/Users/BILLP/go/pkg/mod/github.com/konimarti/opc@v0.3.1/connection_windows.go:161 +0xb8
github.com/konimarti/opc.NewConnection({0x13423410, 0x12}, {0x137d6238, 0x1, 0x1}, {0x0, 0x0, 0x0})
        C:/Users/BILLP/go/pkg/mod/github.com/konimarti/opc@v0.3.1/connection_windows.go:457 +0x52
github.com/lpc921/telegraf-execd-opcda/plugins/inputs/opcda.(*Opcda).Start(0x136c5090, {0xbbb6f4, 0x136b88b8})
        C:/Personal/telegraf-execd-opcda/plugins/inputs/opcda/opcda.go:127 +0x131
github.com/influxdata/telegraf/plugins/common/shim.(*Shim).RunInput(0x13781380, 0x3b9aca00)
        C:/Users/BILLP/go/pkg/mod/github.com/influxdata/telegraf@v1.20.0/plugins/common/shim/input.go:40 +0x172
github.com/influxdata/telegraf/plugins/common/shim.(*Shim).Run(0x13781380, 0x3b9aca00)
        C:/Users/BILLP/go/pkg/mod/github.com/influxdata/telegraf@v1.20.0/plugins/common/shim/goshim.go:78 +0x18d
main.main()
        C:/Personal/telegraf-execd-opcda/cmd/opcda/main.go:40 +0x23e

However, on another server with the same configuration it works without any problems.

alexmc1510 commented 6 months ago

Hello. I have the same error. Did you find the way to solve it?

GigaVik commented 6 months ago

Hello. I have the same error. Did you find the way to solve it?

I haven't figured it out yet. But the suspicion is on the OPC DA Automation Wrapper library. It looks like the library got up correctly on the first server, but not on the second. I'm still trying to figure it out. The error that GO issues is similar to errors when the system does not meet the minimum requirements for startup. I'm sorry for my English (Yandex translate)

miguetronic commented 2 months ago

I’m experiencing the same issue. Have there been any updates or solutions identified for this problem?

lpc921 commented 2 months ago

I updated all dependencies to latest. Please test again.

GigaVik commented 2 months ago

I updated all dependencies to latest. Please test again.

Hi! Now, with the same configuration, the program gives me:

C:\Program Files\InfluxData\telegraf\opcda>opcda_amd64 -config opcda_data.conf
Exception 0xc0000005 0x8 0x0 0x0
PC=0x0

runtime.asmstdcall(0x3a0900060009)
        runtime/sys_windows_amd64.s:76 +0x89 fp=0xf5f570 sp=0xf5f550 pc=0x135d89
rax     0x0
rbx     0x9075c0
rcx     0x9577e8
rdx     0x20
rdi     0x7fffffdd000
rsi     0xf5f768
rbp     0xf5f6b0
rsp     0xf5f548
r8      0x9072e0
r9      0x95724a
r10     0xf7a2e8
r11     0xc000004000
r12     0xf5f7b8
r13     0x0
r14     0x906440
r15     0x3
rip     0x0
rflags  0x10246
cs      0x33
fs      0x53
gs      0x2b

C:\Program Files\InfluxData\telegraf\opcda>opcda_i386 -config opcda_data.conf
Exception 0xc0000005 0x8 0x0 0x0
PC=0x0

runtime.asmstdcall(0x20)
        runtime/sys_windows_386.s:44 +0x2a fp=0x32f948 sp=0x32f944 pc=0xd64cba
eax     0x8
ebx     0x14a59ac
ecx     0x0
edx     0x32f970
edi     0x32f94c
esi     0x32f9a4
ebp     0x32f94c
esp     0x32f940
eip     0x0
eflags  0x10206
cs      0x23
fs      0x53
gs      0x2b
lpc921 commented 2 months ago

I was able to reproduce your error by unregistering gbda_aut.dll

You can get the Graybox DA Automation Wrapper here. Follow the installation instruction for this wrapper.

For 32-bit OPC servers on 64-bit systems follow these steps:

Here is my opcda.conf with Gray Simulator:

[[inputs.opcda]]
  name = "sim"
  server = "Graybox.Simulator.1"
  nodes = ["localhost"]
  items = [
    { item = "numeric.sin.int64" },
  ]

Output:

>opcda_i386.exe -config .\opcda.conf
2024/09/02 23:20:22 I! Connecting to Graybox.Simulator.1[localhost]
sim numeric.sin.int64=-63i 1725276024000000000
sim numeric.sin.int64=-37i 1725276025000000000
sim numeric.sin.int64=-7i 1725276026000000000
sim numeric.sin.int64=25i 1725276027000000000
sim numeric.sin.int64=53i 1725276028000000000