• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #38013

21 Feb 2025 12:36AM UTC coverage: 20.212% (-5.6%) from 25.829%
#38013

push

local

web-flow
lowering: Handle malformed `...` expressions (#57480)

Fixes #51572. The expander had a looser definition of a vararg than the
recursive logic destructing the vararg, so a bad expression like `(call
f (... x y))` could cause a stack overflow via indestructible mutant
semi-vararg.

This change produces a saner error in this situation:
```
julia> macro foo(); Expr(:(...), 1, 2, 3); end; (@foo,)
ERROR: syntax: wrong number of expressions following "..." around REPL[1]:1
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1
```

---------

Co-authored-by: Jameson Nash <vtjnash@gmail.com>

9846 of 48714 relevant lines covered (20.21%)

106241.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/stdlib/Sockets/src/PipeServer.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
mutable struct PipeServer <: LibuvServer
4
    handle::Ptr{Cvoid}
5
    status::Int
6
    cond::Base.ThreadSynchronizer
7
    function PipeServer(handle::Ptr{Cvoid}, status)
×
8
        p = new(handle,
×
9
                status,
10
                Base.ThreadSynchronizer())
11
        associate_julia_struct(p.handle, p)
×
12
        finalizer(uvfinalize, p)
×
13
        return p
×
14
    end
15
end
16

17
function PipeServer()
×
18
    pipe = PipeServer(Libc.malloc(Base._sizeof_uv_named_pipe), StatusUninit)
×
19
    iolock_begin()
×
20
    err = ccall(:uv_pipe_init, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cint), eventloop(), pipe.handle, 0)
×
21
    uv_error("failed to create pipe server", err)
×
22
    pipe.status = StatusInit
×
23
    iolock_end()
×
24
    return pipe
×
25
end
26

27
## server functions ##
28

29
accept(server::PipeServer) = accept(server, PipeEndpoint())
×
30

31
function accept_nonblock(server::PipeServer, client::PipeEndpoint)
×
32
    iolock_begin()
×
33
    if client.status != StatusInit
×
34
        error("client is already in use or has been closed")
×
35
    end
36
    err = ccall(:uv_accept, Int32, (Ptr{Cvoid}, Ptr{Cvoid}), server.handle, client.handle)
×
37
    if err == 0
×
38
        client.status = StatusOpen
×
39
    end
40
    iolock_end()
×
41
    return err
×
42
end
43

44
function accept_nonblock(server::PipeServer)
×
45
    client = PipeEndpoint()
×
46
    uv_error("accept", accept_nonblock(server, client) != 0)
×
47
    return client
×
48
end
49

50
function bind(server::PipeServer, name::AbstractString)
×
51
    iolock_begin()
×
52
    @assert server.status == StatusInit
×
53
    err = ccall(:uv_pipe_bind, Int32, (Ptr{Cvoid}, Cstring),
×
54
                server, name)
55
    if err != 0
×
56
        iolock_end()
×
57
        if err != UV_EADDRINUSE && err != UV_EACCES
×
58
            #TODO: this codepath is currently not tested
59
            throw(_UVError("bind", err))
×
60
        else
61
            return false
×
62
        end
63
    end
64
    server.status = StatusOpen
×
65
    iolock_end()
×
66
    return true
×
67
end
68

69
"""
70
    listen(path::AbstractString) -> PipeServer
71

72
Create and listen on a named pipe / UNIX domain socket.
73

74
!!! note
75
    Path length on Unix is limited to somewhere between 92 and 108 bytes (cf. `man unix`).
76
"""
77
function listen(path::AbstractString)
×
78
    sock = PipeServer()
×
79
    bind(sock, path) || throw(ArgumentError("could not listen on path $path"))
×
80
    return listen(sock)
×
81
end
82

83
function connect!(sock::PipeEndpoint, path::AbstractString)
×
84
    iolock_begin()
×
85
    @assert sock.status == StatusInit
×
86
    req = Libc.malloc(Base._sizeof_uv_connect)
×
87
    uv_req_set_data(req, C_NULL)
×
88
    ccall(:uv_pipe_connect, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), req, sock.handle, path,
×
89
          @cfunction(uv_connectcb, Cvoid, (Ptr{Cvoid}, Cint)))
×
90
    sock.status = StatusConnecting
×
91
    iolock_end()
×
92
    return sock
×
93
end
94

95
"""
96
    connect(path::AbstractString) -> PipeEndpoint
97

98
Connect to the named pipe / UNIX domain socket at `path`.
99

100
!!! note
101
    Path length on Unix is limited to somewhere between 92 and 108 bytes (cf. `man unix`).
102
"""
103
connect(path::AbstractString) = connect(PipeEndpoint(), path)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc