Win10 Primitive '_NetAddr_SendMsg' failed and Primitive ‘_GetLangPort’ failed

Hi all,

I’m new to SuperCollider, trying to get it working for FoxDot. I’ve got 3.11.0 freshly installed on a Windows 10 box and I’ve added the FoxDot Quark. On startup, I get a an error, “ERROR: Primitive ‘_GetLangPort’ failed.”. Trying FoxDot.start also fails with “ERROR: Primitive ‘_NetAddr_SendMsg’ failed.” Is it possible that it’s trying to list on a port that something else is already running on? If so, how can I see what port it’s trying to use/change it? Any other ideas what might be wrong?

I’ve already googled and searched the lists, can’t find any reference to _GetLangPort.

Full errors:
ERROR: Primitive ‘_GetLangPort’ failed.
Failed.
RECEIVER:
class NetAddr (000001CDC17B3140) {
instance variables [19]
name : Symbol ‘NetAddr’
nextclass : instance of Meta_Nil (000001CDB16E9580, size=19, set=5)
superclass : Symbol ‘Object’
subclasses : instance of Array (000001CDC1FC1200, size=1, set=2)
methods : instance of Array (000001CDC17B32C0, size=30, set=5)
instVarNames : instance of SymbolArray (000001CDC17B3540, size=4, set=2)
classVarNames : instance of SymbolArray (000001CDC17B36C0, size=1, set=2)
iprototype : instance of Array (000001CDC17B3600, size=4, set=2)
cprototype : instance of Array (000001CDC17B3780, size=1, set=2)
constNames : nil
constValues : nil
instanceFormat : Integer 0
instanceFlags : Integer 0
classIndex : Integer 194
classFlags : Integer 0
maxSubclassIndex : Integer 195
filenameSymbol : Symbol ‘C:\Program Files\SuperCollider-3.11.0\SCClassLibrary\Common\Control\NetAddr.sc’
charPos : Integer 0
classVarIndex : Integer 304
}
CALL STACK:
MethodError:reportError
arg this =
Nil:handleError
arg this = nil
arg error =
Thread:handleError
arg this =
arg error =
Object:throw
arg this =
Object:primitiveFailed
arg this =
Main:startup
arg this =
var didWarnOverwrite = false
^^ The preceding error dump is for ERROR: Primitive ‘_GetLangPort’ failed.
Failed.
RECEIVER: NetAddr

SCDoc: Indexing help-files…
SCDoc: Indexed 1905 documents in 1.01 seconds
ERROR: Primitive ‘_NetAddr_SendMsg’ failed.
Failed.
RECEIVER:
Instance of NetAddr { (000001CDC0A1E3D8, gc=EC, fmt=00, flg=00, set=02)
instance variables [4]
addr : Integer 2130706433
port : Integer 57110
hostname : “127.0.0.1”
socket : nil
}
CALL STACK:
MethodError:reportError
arg this =
Nil:handleError
arg this = nil
arg error =
Thread:handleError
arg this =
arg error =
Object:throw
arg this =
Object:primitiveFailed
arg this =
Server:prPingApp
arg this =
arg func =
arg onFailure =
arg timeout = 0.25
var id = 461163619
var resp =
var task =
Server:boot
arg this =
arg startAliveThread = true
arg recover = false
arg onFailure = nil
Meta_FoxDot:start
arg this =
Interpreter:interpretPrintCmdLine
arg this =
var res = nil
var func =
var code = “FoxDot.start”
var doc = nil
var ideClass =
Process:interpretPrintCmdLine
arg this =
^^ The preceding error dump is for ERROR: Primitive ‘_NetAddr_SendMsg’ failed.
Failed.
RECEIVER: a NetAddr(127.0.0.1, 57110)

Anyone? Or better to file a github issue?

Maybe try “Kill all servers” in the Server menu (of the SC IDE)?

I haven’t seen this specific error before. It’s unusual. That’s probably why you haven’t gotten a quick response.

hjh

Yeah, totally understand that, hence asking if it might make more sense to go to github.

When I kill all servers, I get a new error!

ERROR: Message ‘basename’ not understood.
RECEIVER:
nil
ARGS:
CALL STACK:
DoesNotUnderstandError:reportError
arg this =
Nil:handleError
arg this = nil
arg error =
Thread:handleError
arg this =
arg error =
Object:throw
arg this =
Object:doesNotUnderstand
arg this = nil
arg selector = ‘basename’
arg args = [*0]
Meta_Server:killAll
arg this =
Process:interpretCmdLine
arg this =
^^ The preceding error dump is for ERROR: Message ‘basename’ not understood.
RECEIVER: nil

That suggests that Server.program is nil… which shouldn’t ever be the case.

Possibly something is going wrong during the startup sequence, preventing some of the classes from being initialized.

Maybe try:

  1. Temporarily remove FoxDot quark.
  2. Relaunch SC.
  3. Try to boot the server from the server menu.

If that works, then it may be something in the FoxDot quark. (Just trying to rule that out.)

Is your startup file empty?

Are there any suspicious messages when launching SC?

hjh

I was getting an unable to open UDP socket up above that (those errors were happening right at start), which I did find some references to. No old processes hanging around (and nothing in the startup file), so that was weird, but after a reboot, it started working again.

Got everything enabled again, started FoxDot, and started working on the tutorials, and then realized that SC had disabled my entire audio interface. Persisted across reboots without the software running, although everything showed that it should be working; all my usual troubleshooting showed nothing wrong. Uninstalling SC completely and then rebooting again fixed it.

So, uh, I guess I’m not going to try getting into livecoding after all… can’t deal software that makes a production machine I need for real work this flaky. I could try to dig in further, and, like, sure, open source, etc., but yeah. Wow, no thanks. :-/

For what it’s worth, I’ve never heard of SC completely breaking an audio interface across reboots (and I’ve been involved in SC for 17+ years). There hasn’t been much opportunity to troubleshoot a problem that quite literally no one has ever reported.

Understood that you’re disappointed.

FWIW: my audio production students who are using Windows run into weird audio driver issues that I never see for my Mac-using students. They are not using open-source software. My conclusion from that is: using Windows for audio production is always a compromise and always somewhat risky. You might get lucky or it might fail hard.

So another way forward for you might be to install Ubuntu Studio on a USB stick and boot from it, to try live coding. Configuring audio in Linux isn’t as easy as on Mac (though Ubuntu Studio does most of it for you) but once it’s configured, I’ve found it to be more stable than Windows audio and without the high expense of Mac. You’d have to build SC from source and that’ll be slow on USB, but only once.

hjh

I am not sure if it is reproducible, but I am getting the same error, after updating my windows10 from version 1909 to 2004 and installed docker for windows.

I could fix the issue by Reboot Interpreter from Language menu, then s.boot
just fyi

Hello there,

Does anyone else have this problem? Unfortunately, rebooting the interpreter didn’t help for me. :frowning: Well, even rebooting the PC didn’t either.

I got the same error on scsynth booting up, ERROR: Primitive ‘_GetLangPort’ failed.
I got the same error on “kill all servers”, ERROR: Message ‘basename’ not understood.
I don’t have FoxDot installed.
Relaunching SC and doing it after rebooting the whole Windows doesn’t solve.
Booting the server from the server menu gives me the following:

ERROR: Primitive '_NetAddr_SendMsg' failed.
Failed.
RECEIVER:
Instance of NetAddr {    (000001B332728F68, gc=90, fmt=00, flg=00, set=02)
  instance variables [4]
    addr : Integer 2130706433
    port : Integer 57110
    hostname : "127.0.0.1"
    socket : nil
}

PROTECTED CALL STACK:
	Meta_MethodError:new	000001B332999B00
		arg this = PrimitiveFailedError
		arg what = Failed.
		arg receiver = a NetAddr(127.0.0.1, 57110)
	Meta_PrimitiveFailedError:new	000001B3329A00C0
		arg this = PrimitiveFailedError
		arg receiver = a NetAddr(127.0.0.1, 57110)
	Object:primitiveFailed	000001B33255D740
		arg this = a NetAddr(127.0.0.1, 57110)
	NetAddr:sendStatusMsg	000001B33318A080
		arg this = a NetAddr(127.0.0.1, 57110)
	Server:sendStatusMsg	000001B3336FCBC0
		arg this = localhost
	a FunctionDef	000001B33371D5C0
		sourceCode = "<an open Function>"
	Routine:prStart	000001B33305A600
		arg this = a Routine
		arg inval = 696.1166194

CALL STACK:
	MethodError:reportError
		arg this = <instance of PrimitiveFailedError>
	< closed FunctionDef >
		arg error = <instance of PrimitiveFailedError>
	Integer:forBy
		arg this = 0
		arg endval = 0
		arg stepval = 2
		arg function = <instance of Function>
		var i = 0
		var j = 0
	SequenceableCollection:pairsDo
		arg this = [*2]
		arg function = <instance of Function>
	Scheduler:seconds_
		arg this = <instance of Scheduler>
		arg newSeconds = 696.117195
	Meta_AppClock:tick
		arg this = <instance of Meta_AppClock>
		var saveClock = <instance of Meta_SystemClock>
	Process:tick
		arg this = <instance of Main>
^^ The preceding error dump is for ERROR: Primitive '_NetAddr_SendMsg' failed.
Failed.
RECEIVER: a NetAddr(127.0.0.1, 57110)


Server 'localhost' exited with exit code 1.

On Windows, there’s no process using the port 57110.

Where shall I look at? Any idea or advice?

Update: deleting 3.11.0 and installing 3.11.1 didn’t help. :frowning:

A couple of questions, because some of these details are confusing.

I got the same error on “kill all servers”, ERROR: Message ‘basename’ not understood.

Can you post the full stack trace for this error?

I’m looking at the code path, and I can’t see where basename is being called.

If Server.killAll is throwing an error related to basename, I’m fairly confident this is not coming from the main class library. The other possibility is, maybe there’s a naughty extension overriding killAll. If so, we should find out which one it is and advise the author to change this.

EDIT: There’s a change to killAll in the development branch that removes the use of the program variable. The old version did use program.basename. So the explanation of this error is: SC can’t get a port. This halts the initialization process before the server program variable is set. Then program.basename hits an error because program is nil.

So, solve the port problem, and this problem goes away too. No need to worry about it.

I got the same error on scsynth booting up, ERROR: Primitive ‘_GetLangPort’ failed.

Are you sure this is happening when booting scsynth, or rather sclang?

_GetLangPort is called by NetAddr.langPort. Server boot logic does not use this method at all. So, there is nothing in the s.boot code path that would be invoking this method.

NetAddr.langPort is called in Main:startup: openPorts = Set[NetAddr.langPort];.

So I think you mean that this is happening when starting SC, but not when booting the server.

Sorry to be picky about this, but this is not an easy error to troubleshoot, and we need to be certain exactly when the errors are occurring.

OK, continuing:

_GetLangPort would fail if the internal gUDPport variable (in C++, you wouldn’t see this in SC code) is not set. This variable is supposed to be set in init_OSC(), which is called with a specific port number (because sclang has a command-line option to request a specific port). There are two possible errors that could occur here:

  • Windows only: “sclang: init_OSC: WSAStartup() failed with error code %d” – I’m not sure if this would result in no port
  • Any: “No networking: %s” – this occurs if the gUDPport assignment failed.

So it might be helpful to:

  • Start SC-IDE. No need to boot the server or do anything else, just let the language initialize.
  • Copy/paste the entire post window contents into a message here. Don’t leave anything out. There is some weird error occurring here and we’ll need to be able to see anything out of the ordinary in the startup log.

On Windows, there’s no process using the port 57110.

The issue seems to be with the language port (57120), not the server port.

hjh

FWIW: I was able to reproduce some of this behavior.

sclang tries 10 consecutive port numbers by default (in case the requested one failed).

So I used one sclang instance to open all ports 57120-57130. sclang takes 57120 by default, then: (57121..57130).do { |port| thisProcess.openUDPPort(port) };

Then in a terminal:

$ sclang -u 57120
No networking: unable to bind udp socket

... snip

ERROR: Primitive '_GetLangPort' failed.

^^ Looks familiar? And then s.boot fails too: “ERROR: Primitive ‘_NetAddr_SendMsg’ failed.”

So I think what is happening here is, maybe you have a large number of sclang.exe processes that never quit successfully. The thread so far has been fixating on killing all servers, but that might be the wrong focus.

Maybe try: thisProcess.platform.killAll("sclang.exe") – this will take down the current interpreter along with all the other ones, but you can reboot the interpreter from the IDE Language menu.

hjh

@jamshark70 First of all, thank you very much for having an interest in this issue.

As you already mentioned, indeed it is when the sclang boots up. And I’m putting the log here. Apparently, ht log starts with No networking: unable to bind dup socket.

No networking: unable to bind udp socket
compiling class library...
	Found 848 primitives.
	Compiling directory 'C:\Program Files\SuperCollider-3.11.1\SCClassLibrary'
	Compiling directory 'C:\ProgramData\SuperCollider\Extensions'
	Compiling directory 'C:\Users\San.QICT0123\AppData\Local\SuperCollider\Extensions'
	Compiling directory 'C:\Users\San.QICT0123\AppData\Local\SuperCollider\downloaded-quarks\ddwPatterns'
	Compiling directory 'C:\Users\San.QICT0123\AppData\Local\SuperCollider\downloaded-quarks\MathLib'
	numentries = 883956 / 13707788 = 0.064
	5779 method selectors, 2372 classes
	method table size 14568528 bytes, big table size 109662304
	Number of Symbols 13033
	Byte Code Size 418193
	compiled 379 files in 2.67 seconds

Info: 4 methods are currently overwritten by extensions. To see which, execute:
MethodOverride.printAll

compile done
localhost : setting clientID to 0.
internal : setting clientID to 0.
Class tree inited in 0.02 seconds
ERROR: Primitive '_GetLangPort' failed.
Failed.
RECEIVER:
class NetAddr (000002B13FC6B900) {
  instance variables [19]
    name : Symbol 'NetAddr'
    nextclass : instance of Meta_Nil (000002B0F7C99580, size=19, set=5)
    superclass : Symbol 'Object'
    subclasses : instance of Array (000002B1405777C0, size=1, set=2)
    methods : instance of Array (000002B13FC6BA80, size=30, set=5)
    instVarNames : instance of SymbolArray (000002B13FC6BD00, size=4, set=2)
    classVarNames : instance of SymbolArray (000002B13FC6BE80, size=1, set=2)
    iprototype : instance of Array (000002B13FC6BDC0, size=4, set=2)
    cprototype : instance of Array (000002B13FC6BF40, size=1, set=2)
    constNames : nil
    constValues : nil
    instanceFormat : Integer 0
    instanceFlags : Integer 0
    classIndex : Integer 178
    classFlags : Integer 0
    maxSubclassIndex : Integer 179
    filenameSymbol : Symbol 'C:\Program Files\SuperCollider-3.11.1\SCClassLibrary\Common\Control\NetAddr.sc'
    charPos : Integer 0
    classVarIndex : Integer 295
}
CALL STACK:
	MethodError:reportError
		arg this = <instance of PrimitiveFailedError>
	Nil:handleError
		arg this = nil
		arg error = <instance of PrimitiveFailedError>
	Thread:handleError
		arg this = <instance of Thread>
		arg error = <instance of PrimitiveFailedError>
	Object:throw
		arg this = <instance of PrimitiveFailedError>
	Object:primitiveFailed
		arg this = <instance of Meta_NetAddr>
	Main:startup
		arg this = <instance of Main>
		var didWarnOverwrite = false
^^ The preceding error dump is for ERROR: Primitive '_GetLangPort' failed.
Failed.
RECEIVER: NetAddr


SCDoc: Indexing help-files...
SCDoc: Indexed 1422 documents in 2.37 seconds

Thank God you could reproduce the problem but it seems something else.

Before I run SuperCollider IDE, there’s no process name sclang.

PS C:\> Get-Process -Name sclang
Get-Process : Cannot find a process with the name "sclang". Verify the process name and call the cmdlet again.
At line:1 char:1
+ Get-Process -Name sclang
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (sclang:String) [Get-Process], ProcessCommandException
    + FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand

The port 57120 isn’t listening:

PS C:\> Test-NetConnection 127.0.0.1 -Port 57120
WARNING: TCP connect to (127.0.0.1 : 57120) failed


ComputerName           : 127.0.0.1
RemoteAddress          : 127.0.0.1
RemotePort             : 57120
InterfaceAlias         : Loopback Pseudo-Interface 1
SourceAddress          : 127.0.0.1
PingSucceeded          : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded       : False

After running the SuperCollider IDE, I get the same error message and the only one sclang process.

PS C:\> Get-Process -Name sclang

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    558      35    95452     110096       4.09  12976   1 sclang

I’ve tried executing sclang.exe manually from PowerShell, and I put different port like 8080 then it just worked! I guess the problem is my Windows 10 somehow prevents processes to use the port 57120. :frowning: And I should find where that came from. It could be a firewall or something else.

That seems a reasonable guess. Gosh, Windows is a weird system.

If something is blocking access to all ports in that range, it would explain the error. Seems to be a system configuration problem, then. I have no specific ideas what it could be. (But, whatever it is, it has to block multiple ports – sclang -u 57120 will try 57120 through 57129, and all of them have to fail. So that may narrow down the possibilities.)

hjh

Did someone found a solution for that. Allowing ports in firewall didnt seem to wokr for me ?

Sorry, I wasn’t very sincere with Windows, and I resolved the problem by installing Linux on my laptop. :stuck_out_tongue:

2 Likes

I just reinstalled SC and had this problem too. Searching a bit, and the working solution was on windows - Cannot bind to some ports due to permission denied - Stack Overflow. As I have Hyper-V, I followed the three steps, and it’s working now. I guess that if you don’t have Hyper-V, you’d only run the middle step.

Update: as mentioned below, SC uses default ports 57110 and 57120, so the command has to be run twice, or once with a range of ports which encompasses both.

@Dymaxion it seems this problem is related to Windows and not to livecoding stuff. Still, even if it would have been the case, there’s no reason to grunt at people. While the livecoding community is globally welcoming and helping the most it can, consider not blaming others for not being able to please you. Computer things are changing every day and sometimes it’s broken and that’s it.

2 Likes

Thanks for posting your solution @Koltes

Just to clarify: by default sclang opens port 57120, scsynth opens port 57110.

@MarcinP you’re right, I already forgot! Thanks.

@jamshark70 the fact that SC uses default ports within the range of ephemeral ports (starting at 32768 on many Linux kernels) is problematic. I suggest to solve it that way, which is backward compatible with current behavior. scide launches sclang with arguments -u 0, because at least on targeted platforms, binding to port 0 actually binds to a random, available ephemeral port. The novelty here is that sclang would notify back scide with the actual port number once it has been bound (I know there is some IPC using Boost but I don’t know the details). In addition, a new argument --port-file /some/path could have the port written at the given path (that could even be a socket!) so that other applications without Boost could launch sclang on a guaranteed available port and retrieve it as well. And of course the same applies to scsynth. Any thought?