Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python does not work on ubuntu 64 bit #287

Closed
mwetter opened this issue Sep 30, 2014 · 5 comments · Fixed by #489
Closed

python does not work on ubuntu 64 bit #287

mwetter opened this issue Sep 30, 2014 · 5 comments · Fixed by #489
Labels
Milestone

Comments

@mwetter
Copy link
Member

mwetter commented Sep 30, 2014

On Ubuntu 14.04 64 bit, If dymola is configured to compiled with

Advanced.CompileWith64=2;

then there is a segmentation fault in Buildings.Utilities.IO.Python27.Examples.KalmanFilter.
Running dymosim in gdb gives

mwetter@srg-mw:~/proj/ldrd/bie/modeling/github/lbl-srg/modelica-buildings/Buildings$ gdb ./dymosim 
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./dymosim...(no debugging symbols found)...done.
(gdb) start
Temporary breakpoint 1 at 0x403830
Starting program: /home/mwetter/proj/ldrd/bie/modeling/github/lbl-srg/modelica-buildings/Buildings/dymosim 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 1, 0x00007ffff72e8ca0 in main () from /opt/dymola-2015FD01-x86_64-beta3/bin/lib64/libds.so
(gdb) c
Continuing.
dymosim started
Runtime license not available, trying to check out the Dymola Standard license instead.

[New Thread 0x7ffff4407700 (LWP 10007)]
... "dsin.txt" loading (dymosim input file)

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff78344f4 in PyList_SetItem () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0

Setting Advanced.CompileWith64=1; (e.g., compile as 32 bit) avoids this problem.

@mwetter
Copy link
Member Author

mwetter commented Feb 3, 2016

The above segmentation fault only occurs when dymosim is used to execute the python code. This is also after changing all int with Py_ssize_t.
The following works:

cd Resources/src/python
make -f Makefile.linux prg
./testProgram

It is not clear what causes this segmentation fault.

In OpenModelica, there is also a segmentation fault in PyList_SetItem(), but likely at a different call (as a debugging statement was not printed):

Starting program: /home/mwetter/proj/ldrd/bie/modeling/github/lbl-srg/modelica-buildings/Buildings.Utilities.IO.Python27.Functions.Examples.Exchange 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff2813700 (LWP 7683)]
[New Thread 0x7ffff2012700 (LWP 7684)]
[New Thread 0x7ffff1811700 (LWP 7685)]
[New Thread 0x7ffff1010700 (LWP 7686)]
[New Thread 0x7ffff080f700 (LWP 7687)]
[New Thread 0x7ffff000e700 (LWP 7688)]
[New Thread 0x7fffef80d700 (LWP 7689)]
[New Thread 0x7fffef00c700 (LWP 7690)]
[New Thread 0x7fffee80b700 (LWP 7691)]
[New Thread 0x7fffee00a700 (LWP 7692)]
[New Thread 0x7fffed809700 (LWP 7693)]
[New Thread 0x7fffed008700 (LWP 7694)]
[New Thread 0x7fffec807700 (LWP 7695)]
[New Thread 0x7fffec006700 (LWP 7696)]
[New Thread 0x7fffeb805700 (LWP 7697)]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff75c20c4 in PyList_SetItem () from /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0

mwetter added a commit that referenced this issue Feb 3, 2016
mwetter added a commit that referenced this issue Feb 3, 2016
@mwetter
Copy link
Member Author

mwetter commented Feb 3, 2016

The problem was that the C code uses int rather than size_t, which gave wrong sizes for arrays on 64 bit Linux.

@mwetter
Copy link
Member Author

mwetter commented Feb 5, 2016

@world2005: This is now corrected for Linux 32 and 64 bit on branch issue287_python64, and Buildings.Utilities.IO.Python.UsersGuide has been updated and recompiled 32 and 64 bit binaries for Linux are also committed.

The following works now on Linux:

def r1_r1(xR):
    import numpy as np
    import sklearn as sk
    return 2.*xR

What remains to be done prior to merging to master is:

  • Testing on Windows 32 and 64 bit

@mwetter mwetter added this to the Release 3.0 milestone Feb 5, 2016
@world2005
Copy link

Thank you very much! The package perfectly works!

@tsnouidui
Copy link
Member

The python interface works on Windows 32 bit. However if the libraries are compiled for Windows 64 bit then they will not work on Windows 64 bit machine. The problem comes from the function Py_DECREF which causes a run-time failure on Windows 64 bit. This can be reproduced in the pythonInterpreter.c or testProgram.c (both available in Buildings/Resources/src/python).
In summary, the Windows 32 bit libraries can work either with the 32 bit of Dymola or the 64 bit of Dymola when Advanced.Compile64=0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants