[nanomsg] Re: NNG DLL not reentrant, not thread safe

  • From: "Garrett D'Amore" <garrett@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Mon, 06 Nov 2017 20:03:47 +0000

*Sigh*.  As I have documented, I have a test program that demonstrates
quite the reverse, running various protocols and transports mixed together
(at random even!) with multiple threads and it works without issue.  (See
multistress.c in the tests/ directory of the nng repo.)  If someone
presents me a test case in C that demonstrates otherwise, I’ll be happy to
consider the problem further.


On Mon, Nov 6, 2017 at 11:49 AM Michael Powell <mwpowellhtx@xxxxxxxxx>
wrote:

Fellow Travelers,

At the moment I have a strong suspicion that NNG threaded DLL
integration does not work. It is interesting that the code can be
packaged that way, but running in a threaded environment is a
non-starter. I've documented this fact at length in issues 151, 153,
and to some extent 150.

https://github.com/nanomsg/nng/issues/151
https://github.com/nanomsg/nng/issues/153
https://github.com/nanomsg/nng/issues/150

This is not a "C test case issue", when I've demonstrated that the C
calling conventions work very well as long as test fixtures are run
individually. Therefore, the C calling conventions into the DLL are my
starting point, and not "the C code".

However, when multiple test cases are running concurrently, each in a
different thread, none of them work. It doesn't matter what
protocol/transport is in play; I've tried homogeneous as well as
heterogeneous combinations.

The only error message I receive is a Visual Studio 2015 Test Runner error:

Logs from me test fixtures:

    BusTests.That_Bus1_delivers_message_to_both_Bus2_and_Bus3 [0:00.000]
Aborted
Current process Id: 12004
Managed thread Id: 9 // <==============
Running protocol tests for address family 'IPv4'.
Testing using address 'tcp://127.0.0.1:10368'.
Given three 'Nanomsg2.Sharp.Protocols.Bus.LatestBusSocket' instances.

    PipelineTests.Load_balancing_works [0:00.000] Aborted
Current process Id: 12004
Managed thread Id: 11 // <==============
Running protocol tests for address family 'IPv4'.
Testing using address 'tcp://127.0.0.1:10304'.

And the runner:

2017.11.06 14:42:23.434   ERROR Process

C:\Users\Michael\AppData\Local\JetBrains\Installations\ReSharperPlatformVs14\JetBrains.ReSharper.TaskRunner.CLR45.x64.exe:12004
exited with code '3'.

Versus a successful run individually:

    BusTests.That_Bus1_delivers_message_to_both_Bus2_and_Bus3 [0:00.272]
Success
Current process Id: 10944
Managed thread Id: 9 // <==============
Running protocol tests for address family 'IPv4'.
Testing using address 'tcp://127.0.0.1:10368'.
Given three 'Nanomsg2.Sharp.Protocols.Bus.LatestBusSocket' instances.
  And messages can be delivered.
    And receive times out.
    And Bus1 delivers message to both Bus2 and Bus3.

    PipelineTests.Load_balancing_works [0:00.406] Success
Current process Id: 1576
Managed thread Id: 9 // <==============
Running protocol tests for address family 'IPv4'.
Testing using address 'tcp://127.0.0.1:10304'.

Cheers,

Michael Powell


Other related posts: