EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Troubleshooting MMF Initialization

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#10608
Posted: 07/16/2009 12:01:17
by Tim Sullivan (Standard support level)
Joined: 06/25/2008
Posts: 26

Hi,
What is the best way to trouble shoot a -1 errocode from MMFTransport setActive?
Currently, our COM object generates a unique string:
$XYZ$_TEST_[PID][TID] (where [PID] and [TID] are the process and thread IDs of the current instance.

This unique string is used as the MessengerName for the MMFTransport.
We have a client that is running into the following problem, while using our COM object: Our code works for a couple instantiations, and then starts encountering the EMCError exception when calling setActive, with ErrorCode = -1.

What's the best way to track down the root cause of this issue?
We tried using procmon, filtering for their app name, but could not find anything useful. Is there a tool you recommend for getting more information?

I'm assuming that -1 is a general failure error, or is does that return code mean anything specific?

Thanks.
#10617
Posted: 07/19/2009 10:29:42
by Eugene Mayevski (EldoS Corp.)

I apologize for the late reply. What code package and version of MSgConnect are you using?
#10619
Posted: 07/20/2009 23:28:09
by Tim Sullivan (Standard support level)
Joined: 06/25/2008
Posts: 26

This problem is displaying in MsgConnect C++ library. I believe we are only one release back from the lastest release.
#10620
Posted: 07/21/2009 06:01:09
by Eugene Mayevski (EldoS Corp.)

We don't have -1 as the error code anywhere in the code. But in C++ code base we have the following:

Code
      TRY_BLOCK
        {
         FReceiverThread->Initialize(this);
        }
      CATCH_EVERY
        {
         delete FReceiverThread; FReceiverThread = NULL;
         initFailed = true;
      }
      
      if (true == initFailed)
#ifndef USE_CPPEXCEPTIONS
         RaiseException(1, 0, 0, NULL);
#else
         throw EMCError(0);
#endif   


As you can see, the actual error is not reported. What you can do is strip the CATCH_EVERY part. In this case your code will be able to catch the actual exception, thrown by FReceiverThread->Initialize(). And in FReceiverThread->Initialize() you will need to check what error codes are used when the exception is thrown: in one of the latest releases I updated those error codes to be more descriptive, but I don't remember if that was the last build or one of the previous builds. In any case the above should give you the idea how to track the problem.

But what can cause it? In general, both PID and ThreadID are guaranteed to be unique only during lifetime of the process or thread respectively. This means that they can be reused later. And this might cause problems for your code. But this is just one of possible reasons.


Sincerely yours
Eugene Mayevski
#10639
Posted: 07/23/2009 23:31:35
by Tim Sullivan (Standard support level)
Joined: 06/25/2008
Posts: 26

Hi Eugene,
Thanks for the response.
I'll look into the debugging suggestions you suggested.
In the meantime, I did have some questions about MMFTransport supporting Multi-Threading applications:
These problems seem to be popping up in multi-threaded apps, same application but different threads.
In our code, our MessengerName contains the PID and TID of the current instance.
Does the MMFTransport support multi-threaded apps? What considerations should be made when initializing MMFTransport to support multi-threading?
Please let me know if you need more information.
Thanks.
#10644
Posted: 07/24/2009 04:54:31
by Eugene Mayevski (EldoS Corp.)

I am not sure that I understand your question right. Are you using MMFTransport in one process to communicate between different threads? If yes, wouldn't it be easier to use DirectTransport instead? MMFTransport is an overkill, as it creates two worker threads for each transport instance.


Sincerely yours
Eugene Mayevski
#10661
Posted: 07/24/2009 12:12:57
by Tim Sullivan (Standard support level)
Joined: 06/25/2008
Posts: 26

Hi Eugene,
Currently, we use MMF to communicate between our COM object and a SEPERATE .NET service.
In the com object, we initialize the MMFtransport with the previously reported string (mix of PID and TID).
Our clients appear to be having a problem when they use our com object in a multi-threaded manner. At this point, the MMF initialization fails with the previously reported -1, Unspecified Error.

Is this behaviour supported by MMF?
#10662
Posted: 07/24/2009 13:59:05
by Eugene Mayevski (EldoS Corp.)

As long you use unique MessengerName, you can have as many MMFTransport instances as you need (well, this number is limited, but with a very high number, which is many thousands). As you have a client-server architecture, you can use GetTickCount+ThreadID as MessengerName. This will be really unique.

But I think that maybe you have some permission-related problem. The easiest way to find this out is to modify the code as I described above in order to catch the actual exception. After modification you will have a memory leak if the exception is raised, but this is not a big problem in that condition.

Also I must repeat that we don't use exception with error code -1 in MMFTransport. There must be something else. Code modification should show, what it is.


Sincerely yours
Eugene Mayevski
#10672
Posted: 07/27/2009 09:53:18
by Tim Sullivan (Standard support level)
Joined: 06/25/2008
Posts: 26

Hi Eugene,
I'm working on setting up a test platform for this issue in-office, and then I'll make the changes you suggested to better determine the cause of the error we're seeing.
I did want to apologize for giving you incorrect information, regarding the error code. You're absolutely right, the error code is not -1. Due to log file formatting in our code, there was some confusion reporting the actual code. We are actually seeing error codes: 0, or 1 (two different sites reporting the different error codes).

I don't know if this info helps any, but I wanted to get you the correct data.
Thanks.
#10673
Posted: 07/27/2009 10:20:58
by Eugene Mayevski (EldoS Corp.)

As you can see from the above quoted code, the error code can be 0 or 1 depending on whether CPP exceptions are enabled. In both cases this doesn't change the given answers.


Sincerely yours
Eugene Mayevski
Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.

Reply

Statistics

Topic viewed 11485 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!