kersing / packet_forwarder

Multi protocol packet forwarder supporting the TTN gateway-connector protocol.
Other
85 stars 56 forks source link

Segmentation fault on sigint #10

Open hilt0n opened 6 years ago

hilt0n commented 6 years ago

After a CTRL-C, the process is normally stopping. However, after termination of downstream thread, I get a seg fault. The forwarder has been compiled for an ARM Cortex-A5. ` Multi Protocol Packet Forwarder for Lora Gateway Version: 3.0.0 Lora concentrator HAL library version info Version: 5.0.1; Options: native;


INFO: Little endian host `

`[...] INFO: Successfully contacted server router.eu.thethings.network INFO: Successfully contacted server iot.semtech.com INFO: [main] Starting the concentrator INFO: [main] concentrator started, radio packets can now be received.

INFO: Disabling GPS mode for concentrator's counter... INFO: JIT thread activated. INFO: [up] Thread activated for all servers. INFO: host/sx1301 time offset=(1509784329s:144413µs) - drift=245385309µs INFO: Enabling GPS mode for concentrator's counter.

^C INFO: End of JIT thread

INFO: End of upstream thread

INFO: End of downstream thread Segmentation fault`

kersing commented 6 years ago

It would help if you could run the software from gdb and provide information on where the issue occurs (in which function).

hilt0n commented 6 years ago

The strange thing is that I have it only without gdb... If you don't see it neither, it could be cause of ressource desctruction between thread, some timing difference could explain that.

By the way, I have seen a mistake concerning the call to freeaddrinfo, it should not be called when getaddrinfo returns an error since the result is null. The freeaddrinfo call will then result to a segafault as well.

i = getaddrinfo(servers[idx].addr, servers[idx].port_down, &hints, &result);
    if (i != 0) {
    MSG("ERROR: [down] getaddrinfo on address %s (port %s) returned: %s\n", servers[idx].addr, servers[idx].port_down, gai_strerror(i));
    //freeaddrinfo(result);
    return;
    }