iegomez / lds

Loraserver device simulator with a simple GUI.
44 stars 25 forks source link

Several segmentation faults #9

Closed 4br3mm0rd closed 4 years ago

4br3mm0rd commented 4 years ago

Hi everyone,

I am trying to build a virtual LoRa environment for testing, based on Chirpstack's server infrastructure.

For some reason, when trying to use this tool, I get segmentation faults when trying to join. I get a segmentation fault at least 50% of the times I click on "Join". Here is one of the error messages:

`panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xa0 pc=0x91a48a]

goroutine 1 [running, locked to thread]:
github.com/iegomez/lds/lds.(*Device).Join(0x0, 0xcd29c0, 0xc00000c1e0, 0x0, 0x0, 0x0, 0x0, 0xc0000920a0, 0xc0000676c0, 0x46a4ff, ...)
    /home/lora/Desktop/lds/lds/lds.go:112 +0x3a
main.join()
    /home/lora/Desktop/lds/device.go:376 +0x4df
main.beginDeviceForm()
    /home/lora/Desktop/lds/device.go:125 +0xb9d
main.main()
    /home/lora/Desktop/lds/main.go:375 +0x312
^C
[1]+  Exit 2`

This happened with different configurations... This specific error happened when I tried to join a second time, after a first time fail.

I also got this segmentation fault error (I don't remember how):

`panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x91a310]

goroutine 1 [running, locked to thread]:
github.com/iegomez/lds/lds.(*Device).SetMarshaler(0x0, 0xbb7d65, 0x4)
    /home/lora/Desktop/lds/lds/lds.go:73 +0x40
main.beginDeviceForm()
    /home/lora/Desktop/lds/device.go:84 +0xd69
main.main()
    /home/lora/Desktop/lds/main.go:375 +0x312
^C
[1]+  Exit 2                  ./gui`

Thank you very much! Hope it helps :)

scartill commented 4 years ago

@4br3mm0rd Could you please also provide your log's contents and a config? Thanks!

4br3mm0rd commented 4 years ago

Sure, here is the configuration file I cannot see the logs since the crash shuts down the UI. Is there a way to have it written into a file?

encoded_type = []
log_level = ""

[mqtt]
  server = "tcp://localhost:1883"
  user = ""
  password = ""
  downlink_topic = "gateway/1111111111111111/event/up"
  uplink_topic = "gateway/1111111111111111/event/down"

[forwarder]
  nserver = ""
  nsport = ""

[band]
  name = "US_902_928"

[device]
  eui = "1111111111111111"
  address = "22222222"
  network_session_encription_key = "33333333333333333333333333333333"
  serving_network_session_integrity_key = "44444444444444444444444444444444"
  forwarding_network_session_integrity_key = "55555555555555555555555555555555"
  application_session_key = "66666666666666666666666666666666"
  marshaler = ""
  nwk_key = ""
  app_key = ""
  join_eui = ""
  mac_version = 0
  profile = "ABP"
  joined = false
  skip_fcnt_check = true

[gateway]
  mac = "1111111111111111"
  bridge_version = ""

[data_rate]
  bandwith = 125
  spread_factor = 7
  bit_rate = 0

[rx_info]
  channel = 0
  code_rate = ""
  crc_status = 0
  frequency = 0
  lora_snr = 0.0
  rf_chain = 0
  rssi = 0

[raw_payload]
  payload = ""
  use_raw = false
  script = "\n// Encode encodes the given object into an array of bytes.\n//  - fPort contains the LoRaWAN fPort number\n//  - obj is an object, e.g. {\"temperature\": 22.5}\n// The function must return an array of bytes, e.g. [225, 230, 255, 0]\nfunction Encode(fPort, obj) {\n\treturn [];\n}\n"
  use_encoder = false
  max_exec_time = 100
  js_object = ""
  fport = 0

[redis]
  addr = ""
  password = ""
  db = 0

[window]
  width = 1200
  height = 1000

[provisioner]
  hostname = ""
  username = ""
  password = ""
  path = ""
  Token = ""
JohnRoesler commented 4 years ago

I am importing the lds package into an automated simulator. Prior to the loraserver v3 release it was working. Now I am seeing same fault.

I am calling device.Uplink(..) in my code, and when running debug, it hits the nil pointer dereference here: https://github.com/iegomez/lds/blob/master/lds/lds.go#L263

Connection established.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x13d2ce7]

goroutine 1 [running]:
github.com/iegomez/lds/lds.(*Device).Uplink(0xc00012a000, 0x156f4a0, 0xc000108000, 0x14d193c, 0x12, 0x102, 0xc00012c000, 0xc0000940c0, 0xc00002a0e8, 0x8, ...)
        /Users/z001w4m/go/pkg/mod/github.com/iegomez/lds@v0.0.0-20200211141717-33c2f46e8464/lds/lds.go:263 +0xd7
4br3mm0rd commented 4 years ago

Here is another segmentation fault that I was able to reproduce:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x91a382]

goroutine 1 [running, locked to thread]:
github.com/iegomez/lds/lds.(*Device).SetMarshaler(0x0, 0xbb98ff, 0x8)
    /home/lora/Desktop/lds/lds/lds.go:90 +0xb2
main.beginDeviceForm()
    /home/lora/Desktop/lds/device.go:84 +0xd69
main.main()
    /home/lora/Desktop/lds/main.go:375 +0x312

This happens with the following configuration when I select "protobuf" as the Marshaler. EDIT: this seems to be independent of the configuration, and to happen anytime I select a marshaler.

encoded_type = []
log_level = ""

[mqtt]
  server = "tcp://10.0.0.13:8000"
  user = ""
  password = ""
  downlink_topic = ""
  uplink_topic = ""

[forwarder]
  nserver = ""
  nsport = ""

[band]
  name = "US_902_928"

[device]
  eui = "1111111111111111"
  address = "22222222"
  network_session_encription_key = "33333333333333333333333333333333"
  serving_network_session_integrity_key = "44444444444444444444444444444444"
  forwarding_network_session_integrity_key = "55555555555555555555555555555555"
  application_session_key = "66666666666666666666666666666666"
  marshaler = ""
  nwk_key = "22222222222222222222222222222222"
  app_key = "76757279736563726574"
  join_eui = ""
  mac_version = 0
  profile = "ABP"
  joined = false
  skip_fcnt_check = true

[gateway]
  mac = ""
  bridge_version = ""

[data_rate]
  bandwith = 125
  spread_factor = 7
  bit_rate = 0

[rx_info]
  channel = 0
  code_rate = ""
  crc_status = 0
  frequency = 0
  lora_snr = 0.0
  rf_chain = 0
  rssi = 0

[raw_payload]
  payload = ""
  use_raw = false
  script = "\n// Encode encodes the given object into an array of bytes.\n//  - fPort contains the LoRaWAN fPort number\n//  - obj is an object, e.g. {\"temperature\": 22.5}\n// The function must return an array of bytes, e.g. [225, 230, 255, 0]\nfunction Encode(fPort, obj) {\n\treturn [];\n}\n"
  use_encoder = false
  max_exec_time = 100
  js_object = ""
  fport = 0

[redis]
  addr = ""
  password = ""
  db = 0

[window]
  width = 1200
  height = 1000

[provisioner]
  hostname = ""
  username = ""
  password = ""
  path = ""
  Token = ""

Hope this helps :)

scartill commented 4 years ago

Thank for reporting! At the least 4br3mm0rd's issues should be solved. If something persists, please let me know.