System.GetNetworkInterface Causes SegFault on linux

Hello,

I have a method in a subclassed ServerSocket that loops through all network interfaces looking for the passed address.

I tested it on a MacBook Pro and linux server and it works just fine, however, on a different linux machine with about the same setup (1 local and 5 ips) it causes a segfault.

Public Sub BindToNIC(Address as string = "")

  Dim Count as integer = System.NetworkInterfaceCount
 
  For i As Integer = 0 To Count-1
    dim NIC as NetworkInterface = System.GetNetworkInterface(i) // <== SegFault Here

    If NIC.IPAddress = Address Then
      self.NetworkInterface = NIC
      Return
    ElseIf NIC.Loopback.IPAddress = Address Then
      self.NetworkInterface = NIC.Loopback
      Return
    End If
  Next
End Sub

Has anyone had any issues with “System.GetNetworkInterface” on linux? I can’t see to find anything that would cause it to segfault.

Any help would be much appreciated.

  • Alex

Maybe report details with Feedback case?

And for time being use NetworkInterfaceMBS class?
http://www.monkeybreadsoftware.net/class-networkinterfacembs.shtml

i made a test in Ubuntu 16.04 32 bit - no problems

I use

BindToNIC(“192.168.0.10”)

[code]Dim Count as integer = System.NetworkInterfaceCount
dim NIC as NetworkInterface

For i As Integer = 0 To Count-1
NIC = System.GetNetworkInterface(i) // <== no SegFault Here

If NIC.IPAddress = Address Then
  self.NetworkInterface = NIC
  MsgBox NIC.IPAddress + " is ok"
  Return
ElseIf NIC.Loopback.IPAddress = Address Then
  self.NetworkInterface = NIC.Loopback
  MsgBox "error"
  Return
End If

Next[/code]

[quote=292786:@Axel Schneider]i made a test in Ubuntu 16.04 32 bit - no problems

I use

BindToNIC(“192.168.0.10”)

[code]Dim Count as integer = System.NetworkInterfaceCount
dim NIC as NetworkInterface

For i As Integer = 0 To Count-1
NIC = System.GetNetworkInterface(i) // <== no SegFault Here

If NIC.IPAddress = Address Then
  self.NetworkInterface = NIC
  MsgBox NIC.IPAddress + " is ok"
  Return
ElseIf NIC.Loopback.IPAddress = Address Then
  self.NetworkInterface = NIC.Loopback
  MsgBox "error"
  Return
End If

Next[/code][/quote]

Thanks, I should add I was using 64bit.

[quote=292749:@Christian Schmitz]Maybe report details with Feedback case?

And for time being use NetworkInterfaceMBS class?
http://www.monkeybreadsoftware.net/class-networkinterfacembs.shtml[/quote]

We’ll see, it would be nice to get it working in pure xojo.

Fill a feedback case, please.
So this bug can be fixed.

[quote=293029:@Christian Schmitz]Fill a feedback case, please.
So this bug can be fixed.[/quote]

Feedback case created!

<https://xojo.com/issue/45533>