Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
alexey_gusev #1
Member since Oct 2010 · 10 posts
Group memberships: Members
Show profile · Link to this post
Subject: Thread safety in Matrix Mobile 1.3.1.1
Hi Alex,

I'm using Matrix Mobile 1.3.1.1 on Windows CE 5.0 device with cf.net v3.5.

My question is if it is safe to call XmppClient methods from different threads, and if Matrix allows re-entrance.

I'm getting access violation exceptions from time to time in a situations like that:
- I have a timer that updates presence
- I set eg OnIq() handler
- I bet timer tick and the callback may happen at 'the same time'

The crashes happen not in ".net" way, ie it doesn't hit my try/catch statements, but all I see is a system popup saying that "Application xxx performed an illegal operation...". The address is always the same though : 0x02B62888.

Does it ring any bells?

BR,
AlexG
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by alexey_gusev:
Does it ring any bells?

hm, no.

OnIq callbacks get raised from socket read events while a presence update is a socket send.

Are you on Tls? Does it crash with and without Tls?

The socket code in the CF is totally different from the socket code in the full .NET framework. So it may be possible that it is not thread safe and throws non .NET exceptions because it calls native code.

Have you tried to synchronize your threads or put it in locks to see if it is a threading problem?
Do you have a simple test case which produces this exceptions?

Alex
Avatar
alexey_gusev #3
Member since Oct 2010 · 10 posts
Group memberships: Members
Show profile · Link to this post
no, unfortunately it seems to be timing related somehow, so I cannot easily reproduce it. It can work for hours and then crash.

StartTls = false, setting it to true doesn't change anything in that regard. I manually call xmppClient.SendPresence() in timer routine. I've tried to synchronize all threads with lock() but as far as I see it didn't help.

Is there any way to get more logging out of matrix? I think it is something related to threads, but cannot put my finger on something definite.

BR,
Alex
Avatar
Alex #4
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by alexey_gusev:
no, unfortunately it seems to be timing related somehow, so I cannot easily reproduce it. It can work for hours and then crash.
ya, its always hard to find problems when they cannot be caused on a simple test case.

Quote by alexey_gusev:
StartTls = false, setting it to true doesn't change anything in that regard. I manually call xmppClient.SendPresence() in timer routine. I've tried to synchronize all threads with lock() but as far as I see it didn't help.
I asked for Tls because previous versions were using unmanaged code for Tls. And your exception looks like it is coming from non .NET code.

Quote by alexey_gusev:
Is there any way to get more logging out of matrix? I think it is something related to threads, but cannot put my finger on something definite.
no, there is no extended logging. When I have a test project I can run it with a debug build and add more logging.

Does the problem happen on all devices or only the CE 5.0?
Does it also happen on the emulator?

Alex
Avatar
alexey_gusev #5
Member since Oct 2010 · 10 posts
Group memberships: Members
Show profile · Link to this post
it happens on WinCE 5.0 devices, didn't try it on the emulator to be honest.

Unfortunately, this particular device model doesn't support Dr. Watson crash dumps, so it's hard to get to the bottom of it.

I think at this stage I will try to get more info and follow this post up when I have it.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS