python / cpython

The Python programming language
https://www.python.org
Other
62.76k stars 30.08k forks source link

Python 3.x crashes when you load a .so file in TCL through tkinter #118051

Open vatsamail opened 5 months ago

vatsamail commented 5 months ago

Crash report

What happened?

Python 3.x (3.9.7) is giving the following error if I try to load a shared object TCL file. If I run manually it works.

Manual method:

shell> tclsh
%load blah.so
%cmd_in_blah

Python method:

from tkinter import *
tcl = Tcl()
ret = tcl.eval("load blah.so")

Gives an error here >>>:

*** Error in `python': free(): invalid pointer: 0x00002ae034fc8d00 ***
Abort

Please help. Thanks in Advance.

CPython versions tested on:

3.9

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

No response

TheLizzard commented 5 months ago

Can you provide blah.so or confirm that it happens with all other shared objects? Making the bug reproducible will help confirm and debug this problem.

For the record, this bug comes from this StackOverflow question.

terryjreedy commented 5 months ago

I don't know if loading .sos this way is supported, but I agree with TheLizzard's SO comment that aborting instead of raising is bad.

vatsamail commented 5 months ago

Can you provide blah.so or confirm that it happens with all other shared objects? Making the bug reproducible will help confirm and debug this problem.

For the record, this bug comes from this StackOverflow question.

Yes, I have a bunch of .so files that happen to work with tclsh 8.5 version when invoked standalone through load function but the same load functions errors out through tkinter. Also, I confirm that tkinter.TclVersion is 8.5

terryjreedy commented 5 months ago

Current tkinter requires 8.5.15, I believe, and only allows that because 1 known Linux distribution (out of about 20) lacked 8.6. So if you are not on that distribution, please retry with up to date tkinter and tcl. Use 3.12 if as all possible since everything before only gets security patches.

vatsamail commented 5 months ago

Tried to run the same with 3.12 Python. The same issue exists.

serhiy-storchaka commented 5 months ago

Could you please run it with a debugger and get a backtrace?

Does it crash in tcl.eval() or during Python shutdown? Try to run Python with the -v option and look whether it starts shutdown (prints "# crear ...") and what it output before crash.