malamute icon indicating copy to clipboard operation
malamute copied to clipboard

mlm_client_set_consumer () with pattern == '*' breaks the stream

Open karolhrdina opened this issue 8 years ago • 2 comments

Assigning character '*' as regex pattern to mlm_client_set_consumer () breaks the stream, to which it is subscribing. Not even the already subscribed clients receive nothing. This does happen with character '*' only (this is the only one we know about SO FAR). A bad regular expression, i.e. '[' does not break it at all."

How to reproduce: Code here: https://gist.github.com/karolhrdina/0fefb5266b57467c0c6e3c17125656f6

Note: There is also PR (https://github.com/zeromq/malamute/pull/216) pending, but for some reason it breaks some Travis tests.

There will be 2 streams created (FIRST, WORLD); one producer per stream, publishing a random number each half a second. For stream FIRST one consumer is created. For stream WORLD two consumers are created, then we wait 5 seconds to show this works, then we create third consumer with pattern '*' and the stream WORLD gets broken.

Tested against latest upstream master (at that time): commit a0f22db7bcb120aa5fb1e941b9f2e38cb1bcc2f6

karolhrdina avatar Dec 05 '16 15:12 karolhrdina

Ok, it is confirmed that the root cause if this issue is in zrex_t in czmq. zrex_new ('*') does not return NULL, zrex_valid () returns true but subsequent zrex_match () hangs.

Further investigation showed that underlying SLRE in czmq.git/src/foreign/slre/ is the cause of this error, i.e.:

slre_compile (&slre, "*"); returns 1
slre_match (&slre, argv [1], strlen (argv [1]), captures); hangs orever (infinite loop/reccursion).

Note: When resolved in czmq, please close this issue as well Action: I will create an issue with CZMQ.git

karolhrdina avatar Dec 06 '16 13:12 karolhrdina

Was pattern * supposed to mean a shell wildcard, while the backend expects regular expressions? Probably the proper fix would be to require consumers to specify real regexes, though a convenience workaround can be to map a specific "*" argument into a ".*" regex (or "^.*$" would the parsing engine require, as some do, or "" as should match anything as well)?

jimklimov avatar May 27 '19 11:05 jimklimov