TcpClient.Connect might throw `NullReferenceException` on macOS
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- csharp
- Ambito
- networking
Direzione di ricerca
Run the reproduction in tcpclient.cs on macOS, then trace the call through TcpClient.Connect(IPEndPoint). Compare the behavior with the reported Linux result; done means closing the client during connection produces a SocketException rather than a NullReferenceException.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
When closing a TcpClient which is connecting, a NullReferenceException is thrown on macOS.
Reproduction Steps
tcpclient.cs
using System.Net;
using System.Net.Sockets;
using var tcpClient = new TcpClient();
using var cts = new CancellationTokenSource(500);
cts.Token.Register(tcpClient.Close);
tcpClient.Connect(new IPEndPoint(new IPAddress([1, 2, 3, 4]), 53));
dotnet run tcpclient.cs
Expected behavior
A SocketException is thrown.
Actual behavior
A NullReferenceException is thrown.
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)
at Program.<Main>$(String[] args) in ~/tcpclient.cs:line 7
Regression?
I don't think it's a regression, I just found about this when running the Lookup_QueryTimesOut_Tcp_Sync test from the DnsClient.NET project which is failing on macOS.
Known Workarounds
I don't know of any workaround.
Configuration
- .NET 10.0.403
- macOS 26.7.1
- arm64
It's specific to macOS but probably not tied to a specific .NET version.
Other information
On Linux, running the same code throws a SocketException.
Unhandled exception. System.Net.Sockets.SocketException (88): Socket operation on non-socket [::ffff:1.2.3.4]:53
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)
at Program.<Main>$(String[] args) in ~/tcpclient.cs:line 7
- Lingua principale
- C#
- Stelle
- 18.4k
- Fork
- 5.8k
- Merge medio
- 2g 12h
- PR unite (30g)
- 600
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di dotnet/runtime
-
area-System.IO untriaged
Difficoltà 2/5 Mezza giornata Idoneità per principianti 72/100
dotnet/runtime#136802 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[wasi] .NET 10: WasmEnableSIMD with AOT fails because WasiApp.targets has -msimd128 commented outApertaarea-Build-mono untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
area-System.ComponentModel untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
dotnet/runtime#136608 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
MemoryMappedFile (Windows): failed MEM_COMMIT is ignored, accessor over reserved memory crashes the processForse già presa @RutulPatel8 l’ha presa oggi. Apertaarea-System.IO bug untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
dotnet/runtime#136599 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area-System.IO untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
dotnet/runtime#136577 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di dotnet/runtime
Issue simili
-
effort:S P3 refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
nightscout/nocturne#3243 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
dasher-project/Dasher-Windows#84 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
libnativeapi/nativeapi#21 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 3 giorni
-
enhancement P3 performance
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
thomhurst/TUnit#7380 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno