Agalin / pidgin_macos_integration

Pidgin plugin adding macOS shell integration
BSD 2-Clause "Simplified" License
8 stars 1 forks source link

Pidgin crashes when plugin is loaded at startup #6

Closed kgraefe closed 5 years ago

kgraefe commented 5 years ago

I managed to build the project using recent Xcode. From there the installation procedure is not clear. I manually copied ~/Library/Developer/Xcode/DerivedData/Pidgin_MacOS_Integration-dfzhbrtqfeopwxdtrkyrvgpzfkfo/Build/Products/Debug/Pidgin MacOS Integration to ~/.purple/plugins/macos-integration.so.

After that I could load the plugin within Pidgin and it seemed to work fine but after quitting, Pidgin crashes on every start. I have to delete the plugin (or disable it in prefs.xml) to get Pidgin running again.

When running pidgin from command line the output is:

> pidgin
Initialization
Load
selfPtr: Optional(0x00007fc66e47f140)
Fatal error: Unexpectedly found nil while unwrapping an Optional value
Illegal instruction: 4
Agalin commented 5 years ago

Somebody tried! 🥳 And a little more seriously: I really don't have time to fix this till ~15 of July. Installation way is standard. Are you running pidgin only from command line? Is it crashing when run through bundle too? Any plugins modifying windows (like merged buddy list + conversations)? If it is crashing in bundled version then I suspect config reading routine. Try removing plugin config from prefs.xml, enable plugin and select ANY sound in its preferences. I'm currently running latest master (even built it with Swift 5 + optimization flags + release mode to shrink binary to 290KB from ~10MB) so it's possible to have quite stable experience.

kgraefe commented 5 years ago

No additional plugins, no non-default settings. In fact I just installed Pidgin through brew and don't even set up any accounts. The bundled version crashes as well.

I will try your suggestion tomorrow. Is it possible to debug the plugin? (I know a thing or two about Pidgin but I am new to MacOS and its different programming languages.)

Agalin commented 5 years ago

It's possible at runtime (by attaching to Pidgin process), not sure about startup debugging or attaching while plugin is not yet loaded.

Agalin commented 5 years ago

Hmm... I'm not able to replicate startup crash even after removing my plugin config entirely. I've added my binary as release. Can you try with it (MacOS 10.14.4+ required)? Can you confirm existence of those directories?

kgraefe commented 5 years ago

I am running MacOS 10.14.5. /Library/Sounds does not exists.

kgraefe commented 5 years ago

Starting Pidgin with pidgin -d reveals a problem but I don't think it's crashing here:

(11:54:50) plugins: Loading saved plugin /Users/kgraefe/.purple/plugins/macos-integration.so
(11:54:50) macos: Load

Initialization
(11:54:50) macos: Initialization

Load
(11:54:50) macos: Load

selfPtr: Optional(0x00007fc88070f440)
(11:54:50) macos: selfPtr: Optional(0x00007fc88070f440)
(11:54:50) macos: Registering callback receiving-im-msg for conversation...
(11:54:50) macos: Registered
(11:54:50) macos: Registering callback receiving-chat-msg for conversation...
(11:54:50) macos: Registered
(11:54:50) macos: Registering callback displayed-im-msg for conversation...
(11:54:50) signals: Signal data for displayed-im-msg not found!
(11:54:50) macos: Registered
(11:54:50) macos: Registering callback displayed-chat-msg for conversation...
(11:54:50) signals: Signal data for displayed-chat-msg not found!
(11:54:50) macos: Registered
Fatal error: Unexpectedly found nil while unwrapping an Optional value
Illegal instruction: 4

The signals displayed-im-msg and displayed-chat-msg are not from issued from the libpurple conversation instance but from the Pidgin conversation instance. Therefore you should use pidgin_conversations_get_handle() instead of purple_conversations_get_handle() for those signals.

kgraefe commented 5 years ago

It is crashing here: https://github.com/Agalin/pidgin_macos_integration/blob/ad23acd333713112581ac0e408c35b40b76f2863/Pidgin%20MacOS%20Integration/main.swift#L446

I guess the Buddy List is not yet initialized when the plugin is load and therefore pidgin_blist_get_default_gtk_blist() returns NULL.

kgraefe commented 5 years ago

I am not sure why it's working for you. The plugins are loaded before the Buddy list created (and that's why it's working when loaded manually). You should listen to the gtkblist-created signal when the Buddy list is not yet initialized. (see e.g. my birthday reminder plugin)

kgraefe commented 5 years ago

I just saw that you're already listening to that signal, so the fix was easy enough (even without knowing Swift). It is working for me now. :-)

Agalin commented 5 years ago

There must be some conditions that make plugins load after buddy list - it literally never crashes on my system. Thanks for the fix. :)