Adding the timeout did not work. I'm fairly new to backtracing, but I
followed the directions from the pidgin wiki and here's what I got:
*When the segfault occurred while running:
Adding buddy...
(20:08:00) oscar: ssi: adding buddy 401787217 to group Buddies
(20:08:00) oscar: Requesting ICQ alias for 401787217(20:08:00) oscar:
icq response: 60 bytes, 579746952, 0x07da, 0x0024
(20:08:00) oscar: ssi: status is 0x000e for a 0x0008 action with name no
item
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb79318d0 (LWP 25796)]
purple_auth_request (data=0xb7eceff4, msg=0x8791008 "") at oscar.c:2533
2533 od = gc->proto_data;
*The backtrace:
#0 purple_auth_request (data=0xb7eceff4, msg=0x8791008 "") at
oscar.c:2533
gc = (PurpleConnection *) 0xb6ebc
account = (PurpleAccount *) 0xbfc027a8
buddy = <value optimized out>
group = <value optimized out>
#1 0x08048fce in request_input_cb ()
No locals.
#2 0xb7e522b6 in ?? () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#3 0xb7e51b88 in g_main_context_dispatch ()
from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#4 0xb7e550eb in ?? () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#5 0xb7e555ba in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#6 0x080491e0 in main ()
No locals.
I also attached the full source code of the program, as simplified as
possible (the only difference is that my password is replaced with
"PASSWORD"). I compile it with:
gcc `pkg-config --libs glib-2.0` -I /usr/include/libpurple/
-I /usr/include/glib-2.0/ -I /usr/lib/glib-2.0/include/ test.c -lpurple
-o test
...if that makes any difference
Let me know if you need any more information.
-Michael
#define CUSTOM_USER_DIRECTORY "/dev/null"
#define CUSTOM_PLUGIN_PATH ""
#define PLUGIN_SAVE_PREF "/purple/master/plugins/saved"
#define UI_ID "master"
/*
* pidgin
*
* Pidgin is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*
*/
#include "purple.h"
#include <glib.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include "defines.h"
#include <stdio.h>
/**
* The following eventloop functions are used in both pidgin and purple-text. If your
* application uses glib mainloop, you can safely use this verbatim.
*/
#define PURPLE_GLIB_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR)
#define PURPLE_GLIB_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
typedef struct _PurpleGLibIOClosure {
PurpleInputFunction function;
guint result;
gpointer data;
} PurpleGLibIOClosure;
static void purple_glib_io_destroy(gpointer data)
{
g_free(data);
}
static gboolean purple_glib_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
{
PurpleGLibIOClosure *closure = data;
PurpleInputCondition purple_cond = 0;
if (condition & PURPLE_GLIB_READ_COND)
purple_cond |= PURPLE_INPUT_READ;
if (condition & PURPLE_GLIB_WRITE_COND)
purple_cond |= PURPLE_INPUT_WRITE;
closure->function(closure->data, g_io_channel_unix_get_fd(source),
purple_cond);
return TRUE;
}
static guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function,
gpointer data)
{
PurpleGLibIOClosure *closure = g_new0(PurpleGLibIOClosure, 1);
GIOChannel *channel;
GIOCondition cond = 0;
closure->function = function;
closure->data = data;
if (condition & PURPLE_INPUT_READ)
cond |= PURPLE_GLIB_READ_COND;
if (condition & PURPLE_INPUT_WRITE)
cond |= PURPLE_GLIB_WRITE_COND;
channel = g_io_channel_unix_new(fd);
closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
purple_glib_io_invoke, closure, purple_glib_io_destroy);
g_io_channel_unref(channel);
return closure->result;
}
static PurpleEventLoopUiOps glib_eventloops =
{
g_timeout_add,
g_source_remove,
glib_input_add,
g_source_remove,
NULL,
#if GLIB_CHECK_VERSION(2,14,0)
g_timeout_add_seconds,
#else
NULL,
#endif
/* padding */
NULL,
NULL,
NULL
};
/*** End of the eventloop functions. ***/
gboolean request_input_cb(gpointer data)
{
GCallback ok_cb = data;
ok_cb();
}
static void
*request_input(const char *title, const char *primary, const char *secondary, const char *default_value, gboolean multiline, gboolean masked, gchar *hint, const char *ok_text, GCallback ok_cb, const char *cancel_text, GCallback cancel_cb, PurpleAccount *account, const char *who, PurpleConversation *conv, void *user_data)
{
purple_timeout_add(2, request_input_cb, ok_cb);
}
static PurpleRequestUiOps request_uiops =
{
request_input, /* request_input */
NULL, /* request_choice */
NULL, /* request_action */
NULL, /* request_fields */
NULL, /* request_file */
NULL, /* close_request */
NULL, /* request_folder */
NULL,
NULL,
NULL,
NULL
};
static void
null_ui_init(void)
{
/**
* This should initialize the UI components for all the modules.
*/
purple_request_set_ui_ops(&request_uiops);
}
static PurpleCoreUiOps null_core_uiops =
{
NULL,
NULL,
null_ui_init,
NULL,
/* padding */
NULL,
NULL,
NULL,
NULL
};
static void
init_libpurple(void)
{
/* Set a custom user directory (optional) */
purple_util_set_user_dir(CUSTOM_USER_DIRECTORY);
/* We do not want any debugging for now to keep the noise to a minimum. */
purple_debug_set_enabled(TRUE);
/* Set the core-uiops, which is used to
* - initialize the ui specific preferences.
* - initialize the debug ui.
* - initialize the ui components for all the modules.
* - uninitialize the ui components for all the modules when the core terminates.
*/
purple_core_set_ui_ops(&null_core_uiops);
/* Set the uiops for the eventloop. If your client is glib-based, you can safely
* copy this verbatim. */
purple_eventloop_set_ui_ops(&glib_eventloops);
/* Set path to search for plugins. The core (libpurple) takes care of loading the
* core-plugins, which includes the protocol-plugins. So it is not essential to add
* any path here, but it might be desired, especially for ui-specific plugins. */
purple_plugins_add_search_path(CUSTOM_PLUGIN_PATH);
/* Now that all the essential stuff has been set, let's try to init the core. It's
* necessary to provide a non-NULL name for the current ui to the core. This name
* is used by stuff that depends on this ui, for example the ui-specific plugins. */
if (!purple_core_init(UI_ID)) {
/* Initializing the core failed. Terminate. */
fprintf(stderr,
"libpurple initialization failed. Dumping core.\n"
"Please report this!\n");
abort();
}
/* Create and load the buddylist. */
purple_set_blist(purple_blist_new());
purple_blist_load();
/* Load the preferences. */
// purple_prefs_load();
/* Load the desired plugins. The client should save the list of loaded plugins in
* the preferences using purple_plugins_save_loaded(PLUGIN_SAVE_PREF) */
purple_plugins_load_saved(PLUGIN_SAVE_PREF);
/* Load the pounces. */
purple_pounces_load();
}
gboolean test(gpointer data)
{
PurpleAccount *account = data;
PurpleBuddy *buddy = purple_buddy_new(account, "401787217", NULL);
printf("Adding buddy...\n");
purple_blist_add_buddy(buddy, NULL, purple_find_group("Buddies"), NULL);
purple_account_add_buddy(account, buddy);
}
int main(int argc, char *argv[])
{
GMainLoop *loop = g_main_loop_new(NULL, FALSE);
/* libpurple's built-in DNS resolution forks processes to perform
* blocking lookups without blocking the main process. It does not
* handle SIGCHLD itself, so if the UI does not you quickly get an army
* of zombie subprocesses marching around.
*/
signal(SIGCHLD, SIG_IGN);
init_libpurple();
printf("libpurple initialized.\n");
PurpleAccount *account = purple_account_new("579746952", "prpl-icq");
purple_account_set_password(account, "PASSWORD");
purple_accounts_add(account);
purple_account_set_enabled(account, UI_ID, TRUE);
purple_timeout_add_seconds(10, test, account); //gives the account time to connect first
g_main_loop_run(loop);
return 0;
}
_______________________________________________
[email protected] mailing list
Want to unsubscribe? Use this link:
http://pidgin.im/cgi-bin/mailman/listinfo/support