Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Python 2 interface: crash with sqllite3 module loaded #396

Ennea opened this Issue Feb 3, 2013 · 14 comments


None yet
5 participants

Ennea commented Feb 3, 2013

Hooking the "Your Message" and/or "Your Action" text events with xchat.hook_print(), then using xchat.command() to use the "SAY" and/or "ME" command (depending on which event you hooked, if not both) will crash HexChat. Using the command normally through the client works just fine, using it in any Python plugin after it has been hooked before will lead to a crash.

OS: Windows 7 x64 Professional
HexChat 2.9.4
Python 2.7.3


Arnavion commented Feb 3, 2013

Additional info from talking on IRC:

The crash only happens when calling xchat.command("SAY ...") from anywhere in any Python plugin, after one hook handler has been registered for "Your Message" (and similar for ME and Your Action). Specifically, the following do NOT crash:

  1. Hooking the event but not calling the command from Python.
  2. Hooking the event and calling the command from the textbox with /SAY or /ME. Hook does get called.
  3. Calling the command from Python but not hooking the event.

Ennea commented Feb 3, 2013

Yup, I can confirm that what Arnavion says is correct. Test code I created to make sure my code was not the culprit:

import xchat
import sqlite3

__module_name__        = "Test"
__module_version__     = "1.0"
__module_description__ = "Let's try things!"

def TestFunc(word, wordEOL, userData):
      return xchat.EAT_NONE

def TestCmd(word, wordEOL, userData):
      xchat.command("ME test")
      return xchat.EAT_NONE

xchat.hook_print("Your Action", TestFunc)
xchat.hook_command("testpy", TestCmd)

If, in fact, this code is also faulty.. well, that'd be embarrassing.


TingPing commented Feb 4, 2013

You made an infinite loop...

Er well looking at your example it isn't, but the description above sounds like it.

Trying your test script it works fine.


Arnavion commented Feb 4, 2013

"Anywhere in any python plugin" == "not necessarily from within the hook itself"


TingPing commented Feb 4, 2013

@Arnavion his example calls it from within another hook and it works if that's what you mean.


Arnavion commented Feb 4, 2013

When I said "from anywhere in any python plugin" in my first comment, it was because the first thing I'd ruled out was that he was creating an infinite recursion.

He himself said "using it in any Python plugin" and I reinforced it, but you ignored it anyway.

Silly TingPing!

Ennea commented Feb 4, 2013

Trying your test script it works fine.

Does it? It does not for me, I wonder why that is..
Also, not an infinite loop, obviously.

Edit: Sorry, apparently, that wasn't the issue. I should've tried running the test code with all other Python plugins disabled. The client will only crash with the test code when the plugin (or any other loaded one, for that matter) will also import the sqlite3 module. I added an import statement to the test code above, give it a spin.


TingPing commented Feb 4, 2013

Still works for me.

Ennea commented Feb 4, 2013

Doesn't for me. Any ideas what might be the issue, then? Because this is awkward..

Edit: Just for the record, client crashes when xchat.command() is called, so when using the created/hooked "testpy" command in this case.

Edit²: Another clarification: I'm using x86 Python and HexChat, running x64 Windows. A friend of mine tried my test code using x64 Python and HexChat and it worked. I'll give that a spin later.

94m3k1n9 commented Feb 4, 2013

Obvious question: did you try it with the most recent version from git?
Does your friend with x64 use 2.9.4 aswell?

Ennea commented Feb 4, 2013

He was using the latest version from git. I'll give it a try later and keep you updated.

Ennea commented Feb 28, 2013

Sorry for the long wait on the update. I gave it a try using the x64 version of both Python and HexChat. No problems there. So the issue only occurs when:

  • using x86 Python and HexChat
  • importing Python's sqlite3 library in any loaded Python plugin
  • hooking an event for the same action that is being performed somewhere else in the code (SAY/ACTION)

To conclude: my sample code above does crash HexChat, but only the x86 version of it. Using it together with Python x64 and HexChat x64 works perfectly fine.


Arnavion commented Feb 28, 2013

Confirmed crash W7 x64 with x86 Hexchat 2.9.4.

Does not crash Linux x64 with x64 Hexchat ToT.

I'm getting this problem too, except with Python 2.7.4 and HexChat 2.9.5, both x64 and on Windows 8.

@TingPing TingPing added the Plugin label May 13, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment