Skip to content

Pythonnet crashes .Net application on exit. #245

Closed

Description

@dmitriyse

If we embed Python.Net into DotNet application, it crashes on Linux.
Crash occurs when application exits.

PythonEngine.Initialize();

try
{
    using (Py.GIL())
    {
        dynamic sysModule = Py.Import("sys");
        Console.WriteLine("Python engine version:");
        Console.WriteLine(sysModule.version);
    }

    // This workaround reduces risk of Mono crash.
    // Problem will be fixed in mono 4.6
    if (Type.GetType("Mono.Runtime") != null)
    {
        Runtime.Py_Main(3, new[] { "/pcfgtest.exe", "-c", "exit" });
    }
    else
    {
        // Program will crash if we will try to do this under Windows.
        //// Runtime.Py_Main(3, new[] { "/pcfgtest.exe", "-c", "exit" });
    }
}
finally
{
    PythonEngine.Shutdown();
}

This is sample of code that produces crash.
Also it contains 'probably workaround".

Console output :

tux@pythonnet:/mnt/Projects/pythonnet/2/src/configtest/bin/Release$ mono pcfgtest.exe
Starting application...
Python.runtime.dll substituted by Python.Runtime-Py35-Linux64.dll.
Python engine version:
3.5.2 (default, Jul  5 2016, 12:43:10)
[GCC 5.4.0 20160609]
Shutting down finalizer thread timed out.
* Assertion at gc.c:867, condition `finalizer_thread_exited' not met

Stacktrace:


Native stacktrace:

        mono() [0x4a77ca]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x113d0) [0x7f48084463d0]
        /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38) [0x7f4807e8b418]
        /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7f4807e8d01a]
        mono() [0x6408c9]
        mono() [0x640ad7]
        mono() [0x640c26]
        mono() [0x5aee5e]
        mono(mono_runtime_cleanup+0xe) [0x5a85de]
        mono() [0x423cf7]
        mono(mono_main+0x10d7) [0x47a087]
        mono() [0x421818]
        /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f4807e76830]
        mono() [0x421c11]

Debug info from gdb:


=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

Aborted (core dumped)

I tried everything - python 2.7, python 3.5, Mono 4.2, 4.4.
It does not matter, behavior always the same.

Also i tried to build with Py_DEBUG under linux (and pass python library from python3.5-dbg package)
I receive assertions on PythonEngine.Init:

  1. Decref -1 Assertions
  2. td_type != NULL Assertion

Activity

  1. royalstream commented on Oct 6, 2016

    @royalstream

    YMMV but here's some potentially useful feedback on this issue.

    I'm using OS X 10.11.3 and Anaconda Python (see the specific version in the outputs).

    Using Mono 4.4.2 I get exactly the same error, even if shrink your code to just this:

    public static void Main(string[] args)
    {
        Environment.SetEnvironmentVariable("PYTHONHOME", "/Users/steven/anaconda");
    
        PythonEngine.Initialize();
    
        try
        {
            using (Py.GIL())
            {
                dynamic sysModule = Py.Import("sys");
                Console.WriteLine("Python engine version:");
                Console.WriteLine(sysModule.version);
            }
        }
        finally
        {
            PythonEngine.Shutdown();
        }
    }

    The error is the following:

    Python engine version:
    2.7.12 |Anaconda 4.1.1 (x86_64)| (default, Jul  2 2016, 17:43:17) 
    [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)]
    Shutting down finalizer thread timed out.
    * Assertion at gc.c:867, condition `finalizer_thread_exited' not met
    
    Stacktrace:
    
    Native stacktrace:
    
        0   mono64                              0x000000010c19966a mono_handle_native_sigsegv + 282
        1   libsystem_platform.dylib            0x00007fff99c93eaa _sigtramp + 26
        2   ???                                 0x00007fff6ec674f2 0x0 + 140735051887858
        3   libsystem_c.dylib                   0x00007fff9fc256e7 abort + 129
        ...

    After upgrading to a newer version of Mono (4.6.1) I get a slightly different error description but I suspect deep down the problem remains the same:

    Python engine version:
    2.7.12 |Anaconda 4.1.1 (x86_64)| (default, Jul  2 2016, 17:43:17) 
    [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)]
    * Assertion at gc.c:910, condition `ret != WAIT_TIMEOUT' not met
    
    Stacktrace:
    
    Native stacktrace:
    
        0   mono64                              0x000000010e55370a mono_handle_native_sigsegv + 282
        1   libsystem_platform.dylib            0x00007fff99c93eaa _sigtramp + 26
        2   ???                                 0x00007fff51768f20 0x0 + 140734560112416
        3   libsystem_c.dylib                   0x00007fff9fc256e7 abort + 129
        4   mono64                              0x000000010e71301d monoeg_log_default_handler + 125
        5   mono64                              0x000000010e7131e0 monoeg_assertion_message + 192
        ...

    Now here's the interesting part:
    If I abstain from using dynamic objects, it never crashes anymore (Mono 4.6.1)
    In other words, I changed the code to sysModule.GetAttr("version").ToString() and the problem is gone.

    Additional Info:

    • I'm actually using F#, not C#, for my development and I was having the same issue.
    • I noticed the problem only happened if I used the FSharp.Interop.Dynamic and Dynamitey libraries. I was about to blame it on those two until I realized the same issue happens with C# if you use dynamic objects.
    • I'm resurrecting an abandoned project from last year. My code didn't change and I don't remember having this issue back then so it could be something that got introduced (in either Mono or Pythonnet) during the last year.
    • I tested this with both pythonnet-2.2.0.dev1 and pythonnet-2.1.0
  2. den-run-ai commented on Oct 7, 2016

    @den-run-ai
    Contributor

    @royalstream @dmitriyse these issues with finalizer were reported recently in Mono:

    https://bugzilla.xamarin.com/show_bug.cgi?id=41833
    https://bugzilla.xamarin.com/show_bug.cgi?id=40399
    https://bugzilla.xamarin.com/show_bug.cgi?id=42665

    Few potential fixes have been made and also workarounds suggested, so have a look there.

    But your second issue with WAIT_TIMEOUT is not fixed yet in Mono:

    https://bugzilla.xamarin.com/show_bug.cgi?id=44355

    If you open a new issue in Mono, then please link it here.

    Can you also try explicitly disposing module like mentioned here:

    https://mail.python.org/pipermail/pythondotnet/2008-May.txt

  3. den-run-ai commented on Oct 7, 2016

    @den-run-ai
    Contributor

    With mono 4.2.4.4 and python 2.7:

    Setting up mono-complete (4.2.4.4-0wheezy1) ...
    Processing triggers for libc-bin (2.19-0ubuntu6.3) ...
    

    I'm getting this error:

    dta@dta-Inspiron-N5050 ~/code/issue1 $ '/home/dta/code/issue1/embedpy.exe'
    Python engine version:
    2.7.6 (default, Jun 22 2015, 18:01:27) 
    [GCC 4.8.2]
    Shutting down finalizer thread timed out.
    
  4. royalstream commented on Oct 14, 2016

    @royalstream

    Now I'm getting the same error on a different machine but without using Dynamic Objects.
    So much for my theory then :|

    For the time being I added Process.GetCurrentProcess().Kill() as the last line of my main function, which is absolutely horrible but avoids the crash until this gets fixed in Mono (I don't believe pythonnet is causing it)

  5. den-run-ai commented on Oct 14, 2016

    @den-run-ai
    Contributor

    @royalstream @dmitriyse can you guys try acquiring the GIL without using Py.GIL()?

  6. royalstream commented on Oct 15, 2016

    @royalstream

    And how do you do that? sorry for the "noob" question but all the code examples I've seen call Py.GIL()

  7. dmitriyse commented on Oct 15, 2016

    @dmitriyse
    ContributorAuthor

    I am using this patched version of Runtime.Shutdown() method:
    (No logic, just magic)

           internal static void Shutdown()
            {
                // This workaround reduces risk of Mono or Linux crash.
                // Problem probably will be fixed in mono 4.6
                if (Path.DirectorySeparatorChar == '/' || Type.GetType("Mono.Runtime") != null)
                {
                    Runtime.Py_Main(3, new[] { "/some.exe", "-c", "exit" });
                }
                else
                {
                    // else
                    // Program will crash if we will try to do this under Windows.
                    //// Runtime.Py_Main(3, new[] { "/some.exe", "-c", "exit" });
                }
    
                AssemblyManager.Shutdown();
                Exceptions.Shutdown();
                ImportHook.Shutdown();
                Py_Finalize();
            }

    And this problem gone.
    This solution works fine, no one issue in last 3 monthes. (On different OS and pythons include conda).

    So I am assuming that bug exists in PythonNet.

    P.S to use this workaround in UCS4 builds you should apply also apply this patch:
    dmitriyse@8638d57

  8. dmitriyse commented on Oct 15, 2016

    @dmitriyse
    ContributorAuthor

    As i understand, PY_DEGUB build should be used to ensure valid reference counting, indexes access and so on. I tried to build and run PythonNet with this flag and received violations near in every place. I think that PythonNet in general requires big "Cleanup", and probably this problem will disappear.

  9. den-run-ai commented on Oct 15, 2016

    @den-run-ai
    Contributor

    @royalstream you could have a look at source code of Py.GIL() ;)

    Here is a quick example:

    public static void Main(string[] args)
    {
        Environment.SetEnvironmentVariable("PYTHONHOME", "/Users/steven/anaconda");
    
        PythonEngine.Initialize();
    
        try
        {
                var pylock = PythonEngine.AcquireLock();
                var sysModule = Py.Import("sys");
                Console.WriteLine("Python engine version:");
                Console.WriteLine(sysModule.version);
    
        }
        finally
        {
              PythonEngine.ReleaseLock(pylock);
              PythonEngine.Shutdown();
        }
    }
    
    
  10. den-run-ai commented on Oct 15, 2016

    @den-run-ai
    Contributor

    As i understand, PY_DEGUB build should be used to ensure valid reference counting, indexes access and > so on. I tried to build and run PythonNet with this flag and received violations near in every place. I think > that PythonNet in general requires big "Cleanup", and probably this problem will disappear.

    @dmitriyse I always thought that PY_DEGUB is only helpful for debugging purposes of CPython interpreter, because it produces debug build of CPython?

    https://docs.python.org/3/c-api/intro.html#debugging-builds

    But let's open a separate issue for Py_DEBUG failures.

  11. royalstream commented on Oct 15, 2016

    @royalstream

    @royalstream you could have a look at source code of Py.GIL() ;)

    Sorry for the misunderstanding, I thought you meant avoiding Py.GIL() and whatever its code was doing.

    I am using this patched version of Runtime.Shutdown() method:
    (No logic, just magic)

    Now I get a really bad malloc/free error, at least on the machine I'm using right now. I'll try this on a different machine next week.

    mono(6365,0x7fff78553000) malloc: *** error for object 0x107f661da: pointer being freed was not allocated
    *** set a breakpoint in malloc_error_break to debug
    Stacktrace:
      at <unknown> <0xffffffff>
      at (wrapper managed-to-native) object.__icall_wrapper_mono_marshal_free (intptr) <IL 0x00007, 0x000b2>
      at (wrapper managed-to-native) Python.Runtime.Runtime.Py_Main (int,string[]) <IL 0x00091, 0x00499>
      at Python.Runtime.Runtime.Shutdown () <IL 0x00040, 0x001db>
      at Python.Runtime.PythonEngine.Shutdown () <IL 0x0000a, 0x0008b>
      at Testing.main (string[]) [0x00098] in /Users/steven/sharp/Python/Testing/Testing.fs:27
      at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <IL 0x00057, 0x00335>
    Native stacktrace:
        0   mono                                0x0000000104bc374a mono_handle_native_sigsegv + 271
        1   libsystem_platform.dylib            0x00007fff8ac0152a _sigtramp + 26
        2   libpython2.7.dylib                  0x0000000107f9c280 sre_char_info + 165472
        3   libsystem_c.dylib                   0x00007fff908286df abort + 129
        4   libsystem_malloc.dylib              0x00007fff90f80041 szone_size + 0
    

    I'm using Mono 4.6.0 (Stable 4.6.0.245/746756c Mon Sep 19 13:57:55 BST 2016)

  12. dmitriyse commented on Oct 15, 2016

    @dmitriyse
    ContributorAuthor

    Looks like you missed this patch.

    P.S to use this workaround in UCS4 builds you should apply also apply this patch:
    dmitriyse@8638d57

    Also you can check binary distro: https://github.com/dmitriyse/pythonnet/releases/tag/v2.2.0-bin-RC
    It should quickly show this trick in work. (Supports only Python 3.5 under x64 os)
    try mono pyboot.exe

  13. royalstream commented on Oct 15, 2016

    @royalstream

    I didn't miss it but it looks like it doesn't apply to my current Python 2.7 installation (which seems to be UCS2):

    >>> import sys
    >>> print sys.maxunicode
    65535
  14. royalstream commented on Oct 15, 2016

    @royalstream

    UPDATE: I installed the Python 3.5 version of Anaconda (which is UCS4) and the patch works great, no more crashes.

    PS: If I run the unpatched version of Pythonnet I get a SIGSEGV so the patch is definitely helping.

  15. den-run-ai commented on Dec 19, 2016

    @den-run-ai
    Contributor

    @dmitriyse @royalstream how are you able to embed Anaconda's CPython using pythonnet on Linux? I tried the following and it is failing with System.DllNotFoundException: python3.5m, but import clr works fine:

    dta@dta-Inspiron-N5050 ~ $ git clone https://github.com/pythonnet/pythonnet
    Cloning into 'pythonnet'...
    remote: Counting objects: 3228, done.
    remote: Compressing objects: 100% (8/8), done.
    remote: Total 3228 (delta 0), reused 0 (delta 0), pack-reused 3220
    Receiving objects: 100% (3228/3228), 2.63 MiB | 1.28 MiB/s, done.
    Resolving deltas: 100% (2226/2226), done.
    Checking connectivity... done.
    dta@dta-Inspiron-N5050 ~ $ cd pythonnet/
    dta@dta-Inspiron-N5050 ~/pythonnet $ which python
    /home/dta/anaconda3/bin/python
    dta@dta-Inspiron-N5050 ~/pythonnet $ ldd `which python`
    	linux-vdso.so.1 =>  (0x00007fff3572f000)
    	libpython3.5m.so.1.0 => /home/dta/anaconda3/bin/../lib/libpython3.5m.so.1.0 (0x00007f6b0dcac000)
    	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6b0da6d000)
    	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f6b0d868000)
    	libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f6b0d665000)
    	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6b0d45d000)
    	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6b0d156000)
    	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6b0cd91000)
    	/lib64/ld-linux-x86-64.so.2 (0x00007f6b0e19e000)
    dta@dta-Inspiron-N5050 ~/pythonnet $ `which python` setup.py install
    running install
    running bdist_egg
    running egg_info
    creating pythonnet.egg-info
    writing dependency_links to pythonnet.egg-info/dependency_links.txt
    writing pythonnet.egg-info/PKG-INFO
    writing top-level names to pythonnet.egg-info/top_level.txt
    writing manifest file 'pythonnet.egg-info/SOURCES.txt'
    reading manifest file 'pythonnet.egg-info/SOURCES.txt'
    writing manifest file 'pythonnet.egg-info/SOURCES.txt'
    installing library code to build/bdist.linux-x86_64/egg
    running install_lib
    running build_ext
    Checking for updates from https://www.nuget.org/api/v2/.
    Currently running NuGet.exe 2.8.0.
    Updating NuGet.exe to 3.4.4-rtm-final.
    Update successful.
    MSBuild auto-detection: using msbuild version '4.0' from '/usr/lib/mono/4.5'.
    Restoring NuGet package UnmanagedExports.1.2.7.
    Restoring NuGet package NUnit.2.6.2.
    Adding package 'UnmanagedExports.1.2.7' to folder '/home/dta/pythonnet/packages'
    Adding package 'NUnit.2.6.2' to folder '/home/dta/pythonnet/packages'
    Added package 'NUnit.2.6.2' to folder '/home/dta/pythonnet/packages'
    Added package 'UnmanagedExports.1.2.7' to folder '/home/dta/pythonnet/packages'
    
    NuGet Config files used:
        /home/dta/.config/NuGet/NuGet.Config
    
    Feeds used:
        /home/dta/.local/share/NuGet/Cache
        https://api.nuget.org/v3/index.json
    
    Installed:
        2 package(s) to packages.config projects
    clang: warning: /home/dta/anaconda3/include/python3.5m: 'linker' input unused
    XBuild Engine Version 12.0
    Mono, Version 4.2.4.0
    Copyright (C) 2005-2013 Various Mono authors
    /home/dta/pythonnet/pythonnet.sln:  warning : The project configuration for project 'clrmodule' corresponding to the solution configuration 'ReleaseMono|x64' was not found.
    XBuild Engine Version 12.0
    Mono, Version 4.2.4.0
    Copyright (C) 2005-2013 Various Mono authors
    		Configuration: ReleaseMono Platform: x64
    runtime.cs(2050,16): warning CS0472: The result of comparing value type `System.IntPtr' with null is always `true'
    /home/dta/pythonnet/pythonnet.sln:  warning : The project configuration for project 'clrmodule' corresponding to the solution configuration 'ReleaseMono|x64' was not found.
    Configuration: ReleaseMono Platform: x64
    Configuration: ReleaseMono Platform: x64
    Configuration: Release Platform: x64
    assemblyinfo.cs(13,50): warning CS0618: `System.Security.Permissions.SecurityAction.RequestMinimum' is obsolete: `This requests should not be used'
    pythonconsole.cs(18,28): warning CS0219: The variable `a' is assigned but its value is never used
    building 'clr' extension
    creating build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/src
    creating build/temp.linux-x86_64-3.5/src/monoclr
    gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/dta/anaconda3/include/python3.5m -c src/monoclr/pynetinit.c -o build/temp.linux-x86_64-3.5/src/monoclr/pynetinit.o -D_REENTRANT -I/usr/lib/pkgconfig/../../include/mono-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
    src/monoclr/pynetinit.c: In function ‘main_thread_handler’:
    src/monoclr/pynetinit.c:129:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (mblen > wlen)
                       ^
    gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/dta/anaconda3/include/python3.5m -c src/monoclr/clrmod.c -o build/temp.linux-x86_64-3.5/src/monoclr/clrmod.o -D_REENTRANT -I/usr/lib/pkgconfig/../../include/mono-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
    src/monoclr/clrmod.c:33:18: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
     static PyObject *_initclr() {
                      ^
    gcc -pthread -shared -L/home/dta/anaconda3/lib -Wl,-rpath=/home/dta/anaconda3/lib,--no-as-needed build/temp.linux-x86_64-3.5/src/monoclr/pynetinit.o build/temp.linux-x86_64-3.5/src/monoclr/clrmod.o -L/home/dta/anaconda3/lib -lpython3.5m -o build/lib.linux-x86_64-3.5/clr.cpython-35m-x86_64-linux-gnu.so -L/usr/lib/pkgconfig/../../lib -lmono-2.0 -lm -lrt -ldl -lpthread -lglib-2.0
    creating build/bdist.linux-x86_64
    creating build/bdist.linux-x86_64/egg
    copying build/lib.linux-x86_64-3.5/clr.cpython-35m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg
    creating stub loader for clr.cpython-35m-x86_64-linux-gnu.so
    byte-compiling build/bdist.linux-x86_64/egg/clr.py to clr.cpython-35.pyc
    installing package data to build/bdist.linux-x86_64/egg
    running install_data
    copying /home/dta/pythonnet/build/lib.linux-x86_64-3.5/Python.Runtime.dll -> build/bdist.linux-x86_64/egg/../../../../anaconda3/lib/python3.5/site-packages
    copying Python.Runtime.dll.config -> build/bdist.linux-x86_64/egg/../../../../anaconda3/lib/python3.5/site-packages
    creating build/bdist.linux-x86_64/egg/EGG-INFO
    copying pythonnet.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
    copying pythonnet.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
    copying pythonnet.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
    copying pythonnet.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
    copying pythonnet.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
    writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
    creating dist
    creating 'dist/pythonnet-2.2.0-py3.5-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
    removing 'build/bdist.linux-x86_64/egg' (and everything under it)
    Processing pythonnet-2.2.0-py3.5-linux-x86_64.egg
    removing '/home/dta/anaconda3/lib/python3.5/site-packages/pythonnet-2.2.0-py3.5-linux-x86_64.egg' (and everything under it)
    creating /home/dta/anaconda3/lib/python3.5/site-packages/pythonnet-2.2.0-py3.5-linux-x86_64.egg
    Extracting pythonnet-2.2.0-py3.5-linux-x86_64.egg to /home/dta/anaconda3/lib/python3.5/site-packages
    pythonnet 2.2.0 is already the active version in easy-install.pth
    
    Installed /home/dta/anaconda3/lib/python3.5/site-packages/pythonnet-2.2.0-py3.5-linux-x86_64.egg
    Processing dependencies for pythonnet==2.2.0
    Finished processing dependencies for pythonnet==2.2.0
    dta@dta-Inspiron-N5050 ~/pythonnet $ csharp
    Mono C# Shell, type "help;" for help
    
    Enter statements below.
    csharp> LoadAssembly("/home/dta/anaconda3/lib/python3.5/site-packages/Python.Runtime.dll") 
    csharp> using Python.Runtime;                                                   csharp> PythonEngine.Initialize();                                              System.DllNotFoundException: python3.5m
      at (wrapper managed-to-native) Python.Runtime.Runtime:Py_IsInitialized ()
      at Python.Runtime.Runtime.Initialize () <0x40fc3400 + 0x0001f> in <filename unknown>:0 
      at Python.Runtime.PythonEngine.Initialize () <0x40fc28d0 + 0x0008f> in <filename unknown>:0 
      at <InteractiveExpressionClass>.Host (System.Object& $retval) <0x40fc28b0 + 0x0000b> in <filename unknown>:0 
      at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) <0x40f48d30 + 0x000dd> in <filename unknown>:0 
      at Mono.CSharpShell.Evaluate (System.String input) <0x40f48c30 + 0x00053> in <filename unknown>:0 
    csharp> quit                                                                    dta@dta-Inspiron-N5050 ~/pythonnet $ python
    Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul  2 2016, 17:53:06) 
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import clr
    >>> exit()
    dta@dta-Inspiron-N5050 ~/pythonnet $ 
    
  16. dmitriyse commented on Dec 19, 2016

    @dmitriyse
    ContributorAuthor

    probably you need to add "CONDA HOME"\lib to LD_LIBRARY_PATH. Or create symlink from "CONDA HOME"\lib\libpython3.5m.so to <python.runtime.dll location>\libpython3.5m.so

  17. den-run-ai commented on Dec 19, 2016

    @den-run-ai
    Contributor

    @dmitriyse do you mean to add \lib to search path of $LD_LIBRARY_PATH?

  18. den-run-ai commented on Dec 19, 2016

    @den-run-ai
    Contributor

    @dmitriyse creating symlink did not resolve this. adding the libpython path to $LD_LIBRARY_PATH did not resolve the issue either.

  19. added a commit that references this issue on Feb 8, 2017
  20. vmuriart commented on Feb 23, 2017

    @vmuriart
    Contributor

    for anyone looking into the LD_LIBRARY_PATH. Here's how it was solved for Travis.

    before_install:
      # Set-up dll path for embedded tests
      - PY_LIBDIR=$(python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))')
      - export LD_LIBRARY_PATH=$PY_LIBDIR:$LD_LIBRARY_PATH
  21. added a commit that references this issue on Feb 27, 2017
  22. vmuriart commented on Feb 27, 2017

    @vmuriart
    Contributor

    @dmitriyse @royalstream can you verify if the latest master have solved your issue? Between #365 and #400 we should have fixed the issues with shutting down.

  23. den-run-ai commented on Feb 27, 2017

    @den-run-ai
    Contributor

    @vmuriart do we have any tests in pythonnet now for code snippets provided above, which reproduced the crash:

    #245 (comment)

  24. vmuriart commented on Feb 27, 2017

    @vmuriart
    Contributor

    Many :). At the beginning of v2.2.2 almost every embedded test produced this error in one way or another. This was one of the reasons we weren't able to run embedded tests before in AppVeyor/Travis.

    The tests in initialize in particular make sure that initialize and shutdown work well. Specific to the example listed though, we have other examples that cover it like AssignNone.

  25. vmuriart commented on Mar 3, 2017

    @vmuriart
    Contributor

    Closing issue. Let us know if the issue is still present after the aforementioned fixes.

  26. added a commit that references this issue on Apr 7, 2017
  27. added a commit that references this issue on Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions