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

Occasional crash in KERNELBASE.dll #609

Open
DiscipleOfEris opened this issue Jul 23, 2023 · 1 comment
Open

Occasional crash in KERNELBASE.dll #609

DiscipleOfEris opened this issue Jul 23, 2023 · 1 comment

Comments

@DiscipleOfEris
Copy link

DiscipleOfEris commented Jul 23, 2023

I am currently using CPPZMQ version 4.8.1.

If there is a better support channel, please let me know.

My application is running on Windows Server 2016. The latest windows updates and drivers are installed. I have run system file checker and it reports no issues.

My application occasionally crashes when attempting to read from the socket. The specific message is:
image
when calling int zmq_msg_recv(zmq_msg_t *msg_, void *s_, int flags_)

_flags_ is zmq::recv_flags::none.

Call stack:
image

Last source code in the call stack I have (I highlighted the offending line with >>>):

ZMQ_NODISCARD
recv_result_t recv(message_t &msg, recv_flags flags = recv_flags::none)
{
>>> const int nbytes =
        zmq_msg_recv(msg.handle(), _handle, static_cast<int>(flags));
    if (nbytes >= 0) {
        assert(msg.size() == static_cast<size_t>(nbytes));
        return static_cast<size_t>(nbytes);
    }
    if (zmq_errno() == EAGAIN)
        return {};
    throw error_t();
}
void listen()
{
    while (true)
    {
        if (!zSocket)
        {
            return;
        }

        try
        {
            chat_message_t message;
>>>         if (!zSocket->recv(message.type, zmq::recv_flags::none))
            {
                send_queue();
                continue;
            }

            int more = zSocket->get(zmq::sockopt::rcvmore);
            if (more)
            {
                std::ignore = zSocket->recv(message.data);
                more        = zSocket->get(zmq::sockopt::rcvmore);
                if (more)
                {
                    std::ignore = zSocket->recv(message.packet);
                }
            }

            parse(message);
        }
        catch (zmq::error_t& e)
        {
            // Context was terminated (ETERM = 156384765)
            // Exit loop
            if (!zSocket || e.num() == 156384765)
            {
                return;
            }
            ShowError("Message: %s\n", e.what());
            continue;
        }
    }
}

I'm not sure what steps I can take to tackle this problem. Our server has 20-70 simultaneous users (only three sessions are permitted from the same IP address). ZMQ doesn't really provide any method for tracking IP address on individual sockets, and it crashes while reading from the socket so I can't check what about the message might have caused it to crash. I'm not sure what other methods I can take to track/log this issue and attempt to develop a pattern.

We get this crash on average 1-2 times a day. We were affected by this exact same crash about four months ago, but it seemed to resolve itself for about 3 months before it cropped up again earlier this month. It is highly intermittent, but frequent enough to be severely disruptive. Server chugs along quite happily for ~12 hours and then crashes (despite the code being inside a try/catch block).

Note that I cannot do much to control the client our users use to connect to our server.

@gummif
Copy link
Member

gummif commented Jul 25, 2023

Are you sure there are no concurrent uses for the zSocket? You could try adding a catch all block (catch(...)) to see if there are other types being thrown.

It looks like this comes from within libzmq so maybe you can try posting there if this does not help.

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

2 participants