Ticket #7563 (closed defect: fixed)

Opened 22 months ago

Last modified 21 months ago

Intermidiate crash uppon connection to sametime server using meanwhile

Reported by: shap Owned by: siege
Milestone: 2.5.3 Component: Sametime
Version: 2.5.2 Keywords: sametime meanwhile crash
Cc: rubchacon, raikon

Description

Hello !

My Environment: Several Windows XP SP2 users with pidgin 2.5.2 connecting to Sametime server 7.5.1 + patches

Problem explanation: Starting from 10-November pidgin intermediate crashes when connecting to Sametime server. It happens to all pidgin users in my office. It is possible that there was a change (patch ?) to sametime server on 09-November.

Attachments

pidgin.RPT (3.0 kB) - added by shap 22 months ago.
Crash Report - pidgin.rpt
st-LoginRedirect.patch (0.6 kB) - added by raikon 22 months ago.
fix segfault when connecting to sametime server with login_redirect
libmeanwhile-1.dll (0.8 MB) - added by datallah 22 months ago.
Patched meanwhile library to avoid crash
pidgin.2.RPT (2.5 kB) - added by shap 22 months ago.
libmeanwhile-1.dll.zip (63.2 kB) - added by jme 22 months ago.
Patched version

Change History

Changed 22 months ago by shap

Crash Report - pidgin.rpt

follow-up: ↓ 2   Changed 22 months ago by datallah

This is crashing in the meanwhile library.

in reply to: ↑ 1   Changed 22 months ago by shap

Replying to datallah:

This is crashing in the meanwhile library.

It seems that the problem is in logon function - here what I see just before crash: meanwhile: session state: handshake acknowledged meanwhile: session state: login sent

  Changed 22 months ago by raikon

It seems that something has changed with the new ST server pidgin cannot process LOGIN_REDIRECTS anymore.

I tracked my intermediate crashes down to the appearances of LOGIN_REDIRECTS. After following that functions in the debugger I found that there is supposed to be a new host name provided by the info field when calling the on_stateChange() handler in the pidgin libsametime protocol library. But that info field is NULL and finally hits the function session_loginRedirect() in libsametime.so (sametime.c) where it is interpreted as new host name and directly sent to a strcmp() to compare it with the old host name:

if(purple_account_get_bool(account, MW_KEY_FORCE, FALSE) ||
      '''(! strcmp(current_host, host))''' ||
      (purple_proxy_connect(NULL, account, host, port, connect_cb, pd) == NULL)) {

That call to strcmp() segfaults because of host being NULL.

The quick fix is to check the host variable to be != NULL as with all the other meanwhile fixes before. That will cause a forced login to happen.

The next question to me is, whether meanwhile also needs to be changed to correctly find the new host name from the login redirect message sent by the new ST server.

Changed 22 months ago by raikon

fix segfault when connecting to sametime server with login_redirect

  Changed 22 months ago by jme

raikon's patch is correct however also need this patch to meanwhile-1.0.2 to fix crash on win32:

diff -ru meanwhile-1.0.2.orig/src/session.c meanwhile-1.0.2/src/session.c
--- meanwhile-1.0.2.orig/src/session.c  2005-12-16 07:11:47.000000000 +1100
+++ meanwhile-1.0.2/src/session.c       2008-11-20 00:02:15.000000000 +1100
@@ -240,7 +240,7 @@

   case mwSession_LOGIN_REDIR:
     g_message("session state: %s (%s)", state_str(state),
-             (char *)info);
+             NSTR((char *)info));
     break;

   default:

  Changed 22 months ago by raikon

it is interesting that it works on Linux without the patch from jme. My log looked like this:

(09:57:40) meanwhile: session state: starting (09:57:40) meanwhile: session state: handshake sent (09:57:40) meanwhile: session state: handshake acknowledged (09:57:40) meanwhile: session state: login sent (09:57:44) meanwhile: session state: login redirected ((null))

The (null) at the end is actually the info field converted to a readable string, just what the NSTR macro would do. Maybe it depends on the glib version how g_message handles NULL input. I'm using glib2-2.16.4-1. Nevertheless, putting the NSTR explicitly around the info parameter should work with all glib versions.

  Changed 22 months ago by jme

raikon: Notice you get an extra line in your log than what shap did above. On win32 it crashes when calling src/session.c:242

    g_message("session state: %s (%s)", state_str(state),
              (char *)info);

quoting comment from NSTR in src/mw_debug.h:

/** replaces NULL strings with "(null)". useful for printf where
    you're unsure that the %s will be non-NULL. Note that while the
    linux printf will do this automatically, not all will. The others
    will instead segfault */
#define NSTR(str) ((str)? (str): "(null)")

So I assume you were using Linux where this bug probably isn't a problem.

  Changed 22 months ago by rubchacon

Could someone point me to the workaround for Win XP SP2? jme, can I patch the meanwhile library as you advise in win without a C compiler? Is there a patched version somewhere?

Thanks

  Changed 22 months ago by jflaflamme

Try to set thoses values to 1 in your accounts.xml

force_login will ignore "redirects", it wasn't working until i set this.

<setting name='fake_client_id' type='bool'>1</setting>
<setting name='force_login' type='bool'>1</setting>

  Changed 22 months ago by rubchacon

they're both set at 1, I think I always had it this way. the fake_client_id value had to be set at 1 when they sunset the notesbuddy client and tried to ban any clients other than sametime 7.5 from accessing servers. I do have the force_login set to 1 as well though.

  Changed 22 months ago by raikon

Unfortunately, enabling "force login" only works around the segfault on Linux, because there it happens in the libsametime lib when it is checked whether to redirect or force login. Since the check for the flag is before the compare of current_host and host it avoids the strcmp() if set to true. Not so on Windows, there the crash already happens in the g_message() function way before in the meanwhile lib, because the printf cannot handle NULL arguments on Windows. BUT, while thinking about it: g_message is only used to print debug messages. Try to turn off debug messages for pidgin and enable the force login. Maybe that is enough to ship around both segfault places.

  Changed 22 months ago by rubchacon

Thanks for responding. How do I turn off debug messages for pidgin in the Win version (not using a debug build)? I looked around and couldn't find instructions for it, and rooted around the menus to no avail either. (I'm an advanced user and have some good notions on programming, but I'm not a developer)

  Changed 22 months ago by raikon

hm, I thought if you do not start pidgin with the -d option, it will not print out the messages and hence, avoid the call to printf(). Try to type pidgin -h on the command prompt and see what options it gives.
Maybe I am also wrong in thinking of how g_message() works when debug messages to stdout is turn off. I cannot test it as I do not have a Windows system. But I'm pretty sure, someone will provide a patched binary soon.

Changed 22 months ago by datallah

Patched meanwhile library to avoid crash

follow-up: ↓ 14   Changed 22 months ago by datallah

I've attached a patched libmeanwhile-1.dll that should prevent the crash, please test it.

Changed 22 months ago by shap

in reply to: ↑ 13   Changed 22 months ago by shap

Replying to datallah:

I've attached a patched libmeanwhile-1.dll that should prevent the crash, please test it.

no, it is not working - but now it is crashing after: meanwhile: session state: login sent meanwhile: session state: login redirected ((null))

I attach crash report as well.

Changed 22 months ago by jme

Patched version

  Changed 22 months ago by jme

Patches applied and recompiled dll contains the two patches (ft_fix.diff and presence_fix_v2.diff) originally from http://www.lilotux.net/~mikael/pub/meanwhile that are used in the pidgin 2.5.2 libmeanwhile-1.dll from here http://developer.pidgin.im/static/win32/meanwhile-1.0.2_daa1-win32.zip

and meanwhile-mwSametimeList_get.patch from here https://bugs.launchpad.net/ubuntu/+source/meanwhile/+bug/261695 which is same as meanwhile_crash.patch from here http://trac.adiumx.com/ticket/10830

and the patch to src/session.c I wrote above.

You will need to set force_login to 1 in your accounts.xml

  Changed 22 months ago by shap

It is working now - after installing the latest libmeanwhile-1.dll, and force_login=1, no more crashes. Thank you very much for your time !

  Changed 22 months ago by Swifty

Thanks, the latest libmeanwhile-1.dll has fixed it for me as well. It also saved me 26Kb of disk space... did someone chop out a large section of code to fix this? Before: 172Kb After : 146Kb

  Changed 22 months ago by datallah@…

(In [d639e3065d1f99c8d438d6de98804498e850df47]):
Patch from Raiko Nitzsche to fix a crash when processing a LOGIN_REDIRECT with unexpected output. References #7563.

  Changed 21 months ago by datallah

Ticket #7651 has been marked as a duplicate of this ticket.

  Changed 21 months ago by jeroen

Just as a note, this libmeanwhile-1.dll.zip seems to fix it for me (#7651) too. Thanks!

  Changed 21 months ago by rubchacon

Both libraries posted here solve the problem. I'd been using datallah's just because it was posted first, but jme's also worked for me and is much smaller, so I'd recommend it over the other one

  Changed 21 months ago by datallah@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to 2.5.3

(In [f29595959d0a02d8035ad35f9569cc11b6ec9ed1]):
Updated included win32 meanwhile library to fix #7563

Note: See TracTickets for help on using tickets.
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!