Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello World example seg faults #150

Closed
smthorn opened this issue Jun 1, 2017 · 3 comments
Closed

Hello World example seg faults #150

smthorn opened this issue Jun 1, 2017 · 3 comments

Comments

@smthorn
Copy link

smthorn commented Jun 1, 2017

When running the ZMQ Guide Hello World example for Julia (hwserver.jl), it seg faults when exiting the program using Ctrl-C while it's waiting to receive a new message. Below are the error messages.

Also, the examples in the ZMQ Guide are outdated, so here is my slightly modified version.

Modified hwserver.jl:

#!/usr/bin/env julia

#
# Hello World server in Julia
# Binds REP socket to tcp://*:5555
# Expects "Hello" from client, replies "World"
#

using ZMQ

context = Context()

# Socket for clients
println("Waiting for client...")
socket = Socket(context, REP)
ZMQ.bind(socket, "tcp://*:5555")

while true
    # Wait for next request from client
    message = unsafe_string(ZMQ.recv(socket))
    println("Received request: $message")

    # Do some 'work'
    sleep(1)

    # Send reply back to client
    ZMQ.send(socket, "World")
end

# classy hit men always clean up when finish the job.
ZMQ.close(socket)
ZMQ.close(context)

Error messages:

$ julia hwserver.jl 
Waiting for client...
^C
signal (2): Interrupt
while loading /home/ddl/Documents/zguide/examples/Julia/hwserver.jl, in expression starting on line 18
unknown function (ip: 0x7f560a8058e8)
uv__epoll_wait at /home/centos/buildbot/slave/package_tarball64/build/deps/srccache/libuv-8d5131b6c1595920dd30644cd1435b4f344b46c8/src/unix/linux-syscalls.c:321
uv__io_poll at /home/centos/buildbot/slave/package_tarball64/build/deps/srccache/libuv-8d5131b6c1595920dd30644cd1435b4f344b46c8/src/unix/linux-core.c:267
uv_run at /home/centos/buildbot/slave/package_tarball64/build/deps/srccache/libuv-8d5131b6c1595920dd30644cd1435b4f344b46c8/src/unix/core.c:354
process_events at ./libuv.jl:82
wait at ./event.jl:147
wait at ./event.jl:27
#wait#17 at ./poll.jl:395
unknown function (ip: 0x7f53f55feee2)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:211 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1950
#wait at ./<missing>:0
recv at /home/ddl/.julia/v0.5/ZMQ/src/ZMQ.jl:530
unknown function (ip: 0x7f53f55fe1c2)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:211 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1950
macro expansion; at /home/ddl/Documents/zguide/examples/Julia/hwserver.jl:20 [inlined]
anonymous at ./<missing> (unknown line)
unknown function (ip: 0x7f53f55fd58f)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:211 [inlined]
jl_toplevel_eval_flex at /home/centos/buildbot/slave/package_tarball64/build/src/toplevel.c:569
jl_parse_eval_all at /home/centos/buildbot/slave/package_tarball64/build/src/ast.c:717
jl_load at /home/centos/buildbot/slave/package_tarball64/build/src/toplevel.c:596
jl_load_ at /home/centos/buildbot/slave/package_tarball64/build/src/toplevel.c:605
include_from_node1 at ./loading.jl:488
unknown function (ip: 0x7f5605aac10b)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:211 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1950
process_options at ./client.jl:265
_start at ./client.jl:321
unknown function (ip: 0x7f5605ad1398)
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:211 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1950
unknown function (ip: 0x401b3d)
unknown function (ip: 0x401446)
__libc_start_main at /build/glibc-9tT8Do/glibc-2.23/csu/../csu/libc-start.c:291
unknown function (ip: 0x40148c)
unknown function (ip: 0xffffffffffffffff)
Allocations: 1130114 (Pool: 1129198; Big: 916); GC: 0

signal (11): Segmentation fault
while loading /home/ddl/Documents/zguide/examples/Julia/hwserver.jl, in expression starting on line 18
Segmentation fault (core dumped)

Julia Version:

julia> versioninfo()
Julia Version 0.5.2
Commit f4c6c9d (2017-05-06 16:34 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5 CPU         660  @ 3.33GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Nehalem)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, westmere)

ZMQ Version: 4.2.1

OS Version:

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:        16.04
Codename:       xenial
@smthorn
Copy link
Author

smthorn commented Jun 14, 2017

Is there a solution to prevent the seg faulting? I've tried using exceptions, but that doesn't work.

@jayvn
Copy link

jayvn commented Feb 28, 2018

I also get segfault when listening is interrupted. Probably an issue with ccall.

@JamesWrigley
Copy link
Member

Closing this because I cannot reproduce it on Julia 1.10 or 1.11 on latest master of ZMQ.jl. FWIW, there are some docs here regarding handling Ctrl + C's: https://docs.julialang.org/en/v1/manual/faq/#catch-ctrl-c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants