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

Core Dumped when authentication plugin returns MOSQ_ERR_AUTH few times #490

Closed
hasunperera opened this Issue Jul 14, 2017 · 16 comments

Comments

Projects
None yet
6 participants
@hasunperera

hasunperera commented Jul 14, 2017

This error popups after few seconds when authentication plugin is returning MOSQ_ERR_AUTH with mosquitto broker 1.4.14

loop.c:488: loop_handle_reads_writes: Assertion pollfds[context->pollfd_index].fd == context->sock' failed. (core dumped)`

@dhanushkad

This comment has been minimized.

dhanushkad commented Jul 14, 2017

I also faced somewhat similar issue.

Im not a very "C" savvy person
Not sure if it breaks anything else, not having the assertion in the code worked for me to get rid of this problem. but still trying to understand if it is essential to the functionality.

"assert(pollfds[context->pollfd_index].fd == context->sock);"

@ralight Assert macro does an application abort on FALSE isnt it? Is it a good idea to have this Assert there since the broker would fail on unsuccessful assertion? Or is it an expected behavior.

@ralight

This comment has been minimized.

Contributor

ralight commented Jul 16, 2017

I haven't yet managed to reproduce this, is there anything else you can tell me about the circumstances around when it happens?

@hasunperera

This comment has been minimized.

hasunperera commented Jul 17, 2017

@dhanushkad I was able to do the same and it solved the issue. But not sure why assert(pollfds[context->pollfd_index].fd == context->sock); returns false.

@ralight I re-created this issue by returning MOSQ_ERR_AUTH for any username or password that is passed to the auth plugin to connect to the Mosquitto broker. After trying to connect to the broker few times from a web-socket client broker gets

loop.c:488: loop_handle_reads_writes: Assertionpollfds[context->pollfd_index].fd == context->sock' failed. (core dumped)`

My auth plugin method is as below,

int mosquitto_auth_unpwd_check(void *user_data, const char *username, const char *password) {
return MOSQ_ERR_AUTH;
}

Mosquitto broker configuration file -

allow_anonymous false
persistence true
persistence_file mosquitto.db

listener 1883
protocol mqtt

listener 1884
protocol websockets
http_dir /home/hasunp/mosquitto/http
certfile /home/hasunp/certificate.crt
cafile /home/hasunp/ca_bundle.crt
keyfile /home/hasunp/private.key
require_certificate false
tls_version tlsv1.2

listener 1885
protocol mqtt
certfile /home/hasunp/certificate.crt
cafile /home/hasunp/ca_bundle.crt
keyfile /home/hasunp/private.key
require_certificate false
tls_version tlsv1.2

auth_plugin /home/hasunp/mosquitto_auth_token.so
auth_opt_http_user_uri http://backend:9005/user/verify
auth_opt_http_acl_uri http://backend:9005/user/verify
auth_opt_bypass_acl true

log_dest file /home/hasunp/mosquitto/mosquitto.log

@ralight

This comment has been minimized.

Contributor

ralight commented Jul 18, 2017

Do you know what version of libwebsockets you are using?

@hasunperera

This comment has been minimized.

hasunperera commented Jul 20, 2017

I'm using libwebsockets-2.2.1 @ralight

ralight added a commit that referenced this issue Jul 26, 2017

@ralight

This comment has been minimized.

Contributor

ralight commented Jul 26, 2017

I believe this is fixed in the commit referenced above. Would you be able to try out the fixes branch to see if it works for you?

@hasunperera

This comment has been minimized.

hasunperera commented Jul 27, 2017

Thank you @ralight ... I'll try out and let you know soon.

@hasunperera

This comment has been minimized.

hasunperera commented Jul 27, 2017

It didn't fix the issue @ralight ..... I get the same error again after returning MOSQ_ERR_AUTH few times

loop.c:489: loop_handle_reads_writes: Assertion 'pollfds[context->pollfd_index].fd == context->sock' failed. Aborted (core dumped)

ralight added a commit that referenced this issue Jul 27, 2017

@ralight

This comment has been minimized.

Contributor

ralight commented Jul 27, 2017

Could you try again with this new fix please?

@hasunperera

This comment has been minimized.

hasunperera commented Jul 31, 2017

Thank you @ralight I'll try out now

@hasunperera

This comment has been minimized.

hasunperera commented Jul 31, 2017

@ralight It seems to be working now.. 👍 I'll run it for few days and report you. Thank you so much

@hasunperera

This comment has been minimized.

hasunperera commented Aug 3, 2017

@ralight Broker was running for few days now.. And it seems to be working fine now 👍

@Tryforce

This comment has been minimized.

Tryforce commented Sep 26, 2017

So, I'm using the latest mosquitto (1.4.14) and libwebsockets-dev v1.7.1-1 and I'm getting this websockets core dump after a couple of failed authentications. Am I missing something? How did you get yours to work exactly @hasunperera?

@hasunperera

This comment has been minimized.

hasunperera commented Sep 28, 2017

@Tryforce Please build mosquitto from this bug fix with libwebsockets-2.2.1
#490

@iegomez

This comment has been minimized.

iegomez commented Oct 24, 2017

Hi, I was having the same problem, building the latest libwebsockets (2.4) and then mosquitto (1.4.14) and mosquitto-auth-plug fixed it for me.

@PierreF

This comment has been minimized.

Contributor

PierreF commented Jan 3, 2018

Closing as the issue seems fixed in latest version. Feel free to reopen if this bug is not fixed.

@PierreF PierreF closed this Jan 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment