Opened 11 years ago

Closed 10 years ago

#2766 closed defect (fixed)

Support Modelica3D on Mac

Reported by: Adam Dershowitz <dersh@…> Owned by: Martin Sjölund
Priority: high Milestone: 1.9.1
Component: Third-Party Libraries Version: trunk
Keywords: Cc:

Description

I am trying to upgrade openmodelica-devel to version 21655 and it fails to build.
What might be related is first that I am building with +modelica3d which has worked fine for a while to build (although I haven't actually been able to get 3d visuals to work). And second that macports just upgraded OpenSceneGraph from 3.2.0 to 3.2.1. That change actually forced the upgrade of openmodelica.
The error is below:

--->  Building openmodelica-devel
Error: org.macports.build for port openmodelica-devel returned: command execution failed
Please see the log file for port openmodelica-devel for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_build.openmodelica.org_macports_lang_openmodelica-devel/openmodelica-devel/main.log
Error: Unable to upgrade port: 1
Error rebuilding openmodelica-devel
    while executing
"error "Error rebuilding $portname""
    (procedure "revupgrade_scanandrebuild" line 395)
    invoked from within
"revupgrade_scanandrebuild broken_port_counts $opts"
    (procedure "macports::revupgrade" line 5)
    invoked from within
"macports::revupgrade $opts"
    (procedure "action_revupgrade" line 2)
    invoked from within
"action_revupgrade $action $portlist $opts"
    (procedure "action_upgrade" line 25)
    invoked from within
"$action_proc $action $portlist [array get global_options]"
    (procedure "process_cmd" line 93)
    invoked from within
"process_cmd $remaining_args"
    invoked from within
"if { [llength $remaining_args] > 0 } {

    # If there are remaining arguments, process those as a command
    set exit_status [process_cmd $remaining..."
    (file "/opt/local/bin/port" line 5254)

and I am also attaching the logfile.

Attachments (1)

main.log (2.8 MB ) - added by Adam Dershowitz <dersh@…> 11 years ago.

Change History (27)

by Adam Dershowitz <dersh@…>, 11 years ago

Attachment: main.log added

comment:1 by anonymous, 11 years ago

I just did a reinstall, without using the modelica3d variant. And, that does build correctly. So, it is a problem with modelica3d.

comment:2 by Martin Sjölund, 10 years ago

If I am not mistaken, it seems like OpenSceneGraph now links against a different c++ library... Now the question is if I should force using GNU libstdc++ or try to detect which library that OSG is linked against :(

comment:3 by Martin Sjölund, 10 years ago

r21807 should fix this. I will close this when I get confirmation it works and none of the jobs looks broken.

comment:4 by Adam Dershowitz <dersh@…>, 10 years ago

It does now compile, but I still can't get any 3d graphics to work. I am not sure that I am doing everything correctly.
What I tried:
I modified dbus-server.py. Now it just tests for OSX and then exits. Instead, my version:

viewer = CDLL("/opt/local/lib/libm3d-osg-gtk.dylib")  # GTK/OSG backend
proc3d = CDLL("/opt/local/lib/libproc3d.dylib") # procedural 3d

Next I run:
python dbus-server.py
That says Running dbus-server and then nothing else.

Next, in OMEdit, I unload ModelicaServices. I then load the library "ModelicaServices 3.2.1 modelica3d"

If I then try to run Modelica.Mechanics.MultBody.Examples.Elementary.Pendulum It compiles but when it runs the simulation I get Simulation process exited with code 1.

I also see this in the message Browser:

[/opt/local/lib/omlibrary/ModelicaServices 3.2.1 modelica3d/Modelica3D/package.mo:459:5-459:33] Warning: No corresponding 'inner' declaration found for component .ModelicaServices.Modelica3D.Controller rev.cylinder.m3d_control declared as 'outer '.
  The existing 'inner' components are:
    .Modelica.Mechanics.MultiBody.World world; defined in scope: Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum. Referenced by 'outer' components: {rev.world}
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.

So, the compile problem seems to be solved, but I still can't run 3d.

--Adam

comment:5 by Martin Sjölund, 10 years ago

https://build.openmodelica.org/Documentation/OpenModelica.Scripting.loadModelica3D.html has some instructions. With Modelica3D you need to create a new model in order to simulate old ones. Just to create that inner m3d_control.

comment:6 by Adam Dershowitz <dersh@…>, 10 years ago

In OpenModelica I just tried without any luck.
I did the same as above. I then tried to run this model:

model DoublePendulum
  extends Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum;
  inner ModelicaServices.Modelica3D.Controller m3d_control;
end DoublePendulum;

It compiles, but then when it tries to simulate I then get this:

Limited backtrace at point of segmentation fault
Process crashed
Simulation process exited with code 0

I also tried to run the example in OMShell. I don't see any errors in that case:

>> loadModelica3D();getErrorString();
loadString("model DoublePendulum
  extends Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum;
  inner ModelicaServices.Modelica3D.Controller m3d_control;
end DoublePendulum;");getErrorString();

>> simulate(DoublePendulum);
Warning: The initial conditions are not fully specified. Use +d=initialization for more information.

But, then I don't see any graphics open, or show anything.
Shouldn't the python dbus server open a window or show the graphics in some way?

comment:7 by Martin Sjölund, 10 years ago

Yes, the python server should open a window. Did that process crash as well or is it still running? If so maybe it is time to play with gdb on the executable. Which is a shame since the latest OSX version doesn't ship very good debugging options :(

comment:8 by Adam Dershowitz <dersh@…>, 10 years ago

The process is still running. All it does, when I run it is this:

Running dbus-server...
No window opens or anything, and there is no change if I run OMEdit, or run a simulation.
It will just sit there like that until I then ctrl-c. At that point it will show me:

^CTraceback (most recent call last):
  File "/Users/adershowitz/Desktop/dbus-server.py", line 190, in <module>
    l.run()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gi/overrides/GLib.py", line 526, in run
    raise KeyboardInterrupt
KeyboardInterrupt

Which executable are you thinking? The dynamic library used by python for the viewer?

comment:9 by Martin Sjölund, 10 years ago

This should mean it is something in the client (executable generated by omc) that crashed and some debugging is needed to find out where things go wrong.

comment:10 by Adam Dershowitz <dersh@…>, 10 years ago

I just ran the executable with gdb. What I get is this:

Starting program: /private/var/folders/s4/0j3cshj161126ygbpbzsdkmd4h24dl/T/OpenModelica_adershowitz/OMEdit/DoublePendulum 

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000001ff1800
0x00000001000e17c1 in _dbus_message_iter_check ()

Not much details, but clearly related to dbus. I suppose that is consistent with it not being able to connect to the dbus server.

comment:11 by Martin Sjölund, 10 years ago

How did you get such a good error-message? My gdb just says:

(gdb) bt
#0  0x0000000100142b34 in ?? ()
#1  0x00000001027e09b0 in ?? ()
#2  0x00000000027f7590 in ?? ()
#3  0x00007fff5fbfd8f0 in ?? ()
#4  0x0000000100143087 in ?? ()
#5  0x00000001027e09b0 in ?? ()
#6  0x00000000027f7590 in ?? ()
#7  0x00007fff5fbfd940 in ?? ()
#8  0x00000001001420b6 in ?? ()
#9  0x0000000000000000 in ?? ()
(gdb) info threads
  Id   Target Id         Frame 
  8    Thread 0x2103 of process 26574 0x0000000100bce716 in ?? ()
  7    Thread 0x2003 of process 26574 0x0000000100bce716 in ?? ()
  6    Thread 0x1f03 of process 26574 0x0000000100bce716 in ?? ()
  5    Thread 0x1e03 of process 26574 0x0000000100bce716 in ?? ()
  4    Thread 0x1d03 of process 26574 0x0000000100bce716 in ?? ()
  3    Thread 0x1c03 of process 26574 0x0000000100bce716 in ?? ()
  2    Thread 0x1b0b of process 26574 0x0000000100bce716 in ?? ()
* 1    Thread 0x1903 of process 26574 0x0000000100142b34 in ?? ()

And valgrind succeeds without error (in the simulation; the graphical client crashes). I don't think I can spend more time on this though.

comment:12 by Adam Dershowitz <dersh@…>, 10 years ago

I'm not sure why the difference. I do also have gdb installed with macports, but I am pretty sure that I am not actually running that version. (when I run gdb I see this: 6.3.50-20050815 (Apple version gdb-1824) but macports is 7.7.1 so I don't think that is the issue ).
I did pass the -g flag to compile. But, it does seem strange that you are seeing no useful information.

After the crash, here is what I see:

(gdb) bt
#0  0x000000010014b7c1 in _dbus_message_iter_check ()
#1  0x000000010014bd1d in _dbus_message_iter_append_check ()
#2  0x000000010014acfb in dbus_message_iter_open_container ()
#3  0x0000000100064b79 in msg_add_entry ()
#4  0x0000000100064c4c in modbus_msg_add_string ()
#5  0x00000001000171e1 in omc_ModelicaServices_modbus_addString (threadData=0x7fff5fbff578, _msg=0x3172b30, _name=0x100065a97 "reference", _val=0x10312ced0 "box_1") at DoublePendulum_functions.c:458
#6  0x0000000100015d29 in omc_ModelicaServices_Modelica3D_createBoxAt (threadData=0x7fff5fbff578, _state={_conn = 0x30ce850, _context = 0x101e46120}, _length=0.059999999999999998, _width=0.059999999999999998, _height=0.5, _tx=0.5, _ty=0, _tz=0, _id=0x100f02d20) at DoublePendulum_functions.c:730
#7  0x00000001000155a1 in omc_Modelica_Mechanics_MultiBody_Visualizers_Advanced_Shape_shapeDescrTo3D (threadData=0x7fff5fbff578, _state={_conn = 0x30ce850, _context = 0x101e46120}, _descr=0x1000710a3 "box", _length=0.5, _width=0.059999999999999998, _height=0.059999999999999998, _at=<value temporarily unavailable, due to optimizations>, _extra=0, _id=0x100f02d20) at DoublePendulum_functions.c:327
#8  0x0000000100041a3d in DoublePendulum_eqFunction_1474 (data=0x7fff5fbff628) at DoublePendulum_06inz.c:18037
#9  0x000000010004ab5a in DoublePendulum_functionInitialEquations (data=0x7fff5fbff628) at DoublePendulum_06inz.c:21555
#10 0x00000001001b90f6 in initialization ()
#11 0x00000001001b400f in initializeModel ()
#12 0x00000001001b4d73 in solver_main ()
#13 0x00000001001d7125 in callSolver ()
#14 0x00000001001d6a05 in startNonInteractiveSimulation ()
#15 0x00000001001d85b1 in _main_SimulationRuntime ()
#16 0x000000010001376d in main (argc=1, argv=0x7fff5fbffa58) at DoublePendulum.c:4485

(gdb) info threads 
  8 0x00007fff81b36716 in __psynch_cvwait ()
  7 0x00007fff81b36716 in __psynch_cvwait ()
  6 0x00007fff81b36716 in __psynch_cvwait ()
  5 0x00007fff81b36716 in __psynch_cvwait ()
  4 0x00007fff81b36716 in __psynch_cvwait ()
  3 0x00007fff81b36716 in __psynch_cvwait ()
  2 0x00007fff81b36716 in __psynch_cvwait ()
* 1 0x000000010014b7c1 in _dbus_message_iter_check ()

I understand that you are busy. I know the feeling. I think that it is probably important to have the ticket, with as much detail as possible, so that it can hopefully be dealt with in the near future, even if not now.

comment:13 by Martin Sjölund, 10 years ago

What version of OSX are you running? XCode doesn't come with gdb anymore (only lldb, which is almost unusable from the terminal when you need to run code as non-root).

comment:14 by Martin Sjölund, 10 years ago

Some quick debugging suggests that a void* is truncated to 32-bit at some place in the code :(

comment:15 by Adam Dershowitz <dersh@…>, 10 years ago

10.9.4 the newest one.
And which gdb shows /usr/bin/gdb so it is not the version from macports. So, I'm not sure where it came from, since googling around, I see that you are correct that it is no longer part of xcode, even with the command line tools.
Maybe an older xcode and it was never removed with the upgrade?

comment:16 by Adam Dershowitz <dersh@…>, 10 years ago

I just tried to use /opt/local/bin/ggdb (which I had installed with macports) and, after code signing, I see the same useless information that you had seen.
But, with just gdb, it shows me the good information.

comment:17 by Martin Sjölund, 10 years ago

Yes. You're lucky you still have the old gdb :)

The omlib-modelicaservices-3.2.1-modelica3d port should be updated within the hour or so; no new omc version should be needed if I am correct:
https://github.com/OpenModelica/modelica3d/commit/7ab6337e8ba0c706664adb1e3530277599f8c601

comment:18 by Adam Dershowitz <dersh@…>, 10 years ago

According to this link http://ntraft.com/installing-gdb-on-os-x-mavericks/ the gdb-apple port should work.

I haven't tried it, so I can't comment beyond that.
I will try it out once it is updated, and let you know.

comment:19 by Martin Sjölund, 10 years ago

The modelica3d port is updated now. Try it :)

comment:20 by Adam Dershowitz <dersh@…>, 10 years ago

Progress, but not solved. Now, the executable seems to run fine. But, when I try to run it the dbus-server crashes with a segmentation fault: 11.
Here is what is reported:

Process:         Python [47572]
Path:            /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier:      Python
Version:         2.7.8 (2.7.8)
Code Type:       X86-64 (Native)
Parent Process:  bash [596]
Responsible:     Terminal [540]
User ID:         1224806835

Date/Time:       2014-08-11 11:02:16.846 -0400
OS Version:      Mac OS X 10.9.4 (13E28)
Report Version:  11
Anonymous UUID:  1D77F421-0BFD-3CEA-3669-D9C3391C1488

Sleep/Wake UUID: E68A739C-9578-4F95-8843-88826DE6FFCD

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000000000be204d8

VM Regions Near 0xbe204d8:
--> 
    __TEXT                 00000001083e2000-00000001083e4000 [    8K] r-x/rwx SM=COW  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libproc3d.dylib               	0x0000000109a6495d std::deque<boost::variant<proc3d::CreateGroup, proc3d::CreateSphere, proc3d::CreateBox, proc3d::CreateCylinder, proc3d::CreateCone, proc3d::CreatePlane, proc3d::LoadObject, proc3d::AddToGroup, proc3d::CreateMaterial, proc3d::ApplyMaterial, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>, std::allocator<boost::variant<proc3d::CreateGroup, proc3d::CreateSphere, proc3d::CreateBox, proc3d::CreateCylinder, proc3d::CreateCone, proc3d::CreatePlane, proc3d::LoadObject, proc3d::AddToGroup, proc3d::CreateMaterial, proc3d::ApplyMaterial, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> > >::push_back(boost::variant<proc3d::CreateGroup, proc3d::CreateSphere, proc3d::CreateBox, proc3d::CreateCylinder, proc3d::CreateCone, proc3d::CreatePlane, proc3d::LoadObject, proc3d::AddToGroup, proc3d::CreateMaterial, proc3d::ApplyMaterial, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) + 9
1   libproc3d.dylib               	0x0000000109a5dbd1 proc3d_create_box + 300
2   _ctypes.so                    	0x0000000108818677 ffi_call_unix64 + 79
3   _ctypes.so                    	0x0000000108818ed8 ffi_call + 856
4   _ctypes.so                    	0x0000000108813d5b _ctypes_callproc + 891
5   _ctypes.so                    	0x000000010880d982 PyCFuncPtr_call + 1058
6   org.python.python             	0x00000001083f7653 PyObject_Call + 99
7   org.python.python             	0x00000001084955ae PyEval_EvalFrameEx + 16030
8   org.python.python             	0x000000010849149d PyEval_EvalCodeEx + 1725
9   org.python.python             	0x000000010841d14c function_call + 364
10  org.python.python             	0x00000001083f7653 PyObject_Call + 99
11  org.python.python             	0x0000000108494c0d PyEval_EvalFrameEx + 13565
12  org.python.python             	0x000000010849149d PyEval_EvalCodeEx + 1725
13  org.python.python             	0x000000010841d14c function_call + 364
14  org.python.python             	0x00000001083f7653 PyObject_Call + 99
15  org.python.python             	0x0000000108494c0d PyEval_EvalFrameEx + 13565
16  org.python.python             	0x000000010849149d PyEval_EvalCodeEx + 1725
17  org.python.python             	0x000000010841d14c function_call + 364
18  org.python.python             	0x00000001083f7653 PyObject_Call + 99
19  org.python.python             	0x0000000108494c0d PyEval_EvalFrameEx + 13565
20  org.python.python             	0x000000010849149d PyEval_EvalCodeEx + 1725
21  org.python.python             	0x000000010841d14c function_call + 364
22  org.python.python             	0x00000001083f7653 PyObject_Call + 99
23  org.python.python             	0x0000000108404946 instancemethod_call + 182
24  org.python.python             	0x00000001083f7653 PyObject_Call + 99
25  org.python.python             	0x00000001083f1f77 PyObject_CallFunctionObjArgs + 359
26  _dbus_bindings.so             	0x0000000109f4d054 DBusPyConnection_HandleMessage + 31
27  _dbus_bindings.so             	0x0000000109f4e7ef _object_path_message + 161
28  libdbus-1.3.dylib             	0x0000000109f865fc _dbus_object_tree_dispatch_and_unlock + 322
29  libdbus-1.3.dylib             	0x0000000109f79279 dbus_connection_dispatch + 594
30  libdbus-glib-1.2.dylib        	0x000000010b0ab201 message_queue_dispatch + 26
31  libglib-2.0.0.dylib           	0x000000010967250e g_main_context_dispatch + 274
32  libglib-2.0.0.dylib           	0x00000001096727fc g_main_context_iterate + 413
33  libglib-2.0.0.dylib           	0x0000000109672a46 g_main_loop_run + 195
34  _ctypes.so                    	0x0000000108818677 ffi_call_unix64 + 79
35  _ctypes.so                    	0x0000000108818ed8 ffi_call + 856
36  _gi.so                        	0x000000010b1ec7f9 pygi_callable_info_invoke + 2938
37  _gi.so                        	0x000000010b1e40c3 _callable_info_call + 140
38  org.python.python             	0x00000001083f7653 PyObject_Call + 99
39  org.python.python             	0x00000001084955ae PyEval_EvalFrameEx + 16030
40  org.python.python             	0x0000000108498fc2 fast_function + 194
41  org.python.python             	0x00000001084948e5 PyEval_EvalFrameEx + 12757
42  org.python.python             	0x000000010849149d PyEval_EvalCodeEx + 1725
43  org.python.python             	0x0000000108490dd6 PyEval_EvalCode + 54
44  org.python.python             	0x00000001084ba944 PyRun_FileExFlags + 164
45  org.python.python             	0x00000001084ba4c1 PyRun_SimpleFileExFlags + 769
46  org.python.python             	0x00000001084d011e Py_Main + 3070
47  libdyld.dylib                 	0x00007fff8dda75fd start + 1

Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib        	0x00007fff81b37662 kevent64 + 10
1   libdispatch.dylib             	0x00007fff8bbac421 _dispatch_mgr_invoke + 239
2   libdispatch.dylib             	0x00007fff8bbac136 _dispatch_mgr_thread + 52

Thread 2:
0   libsystem_kernel.dylib        	0x00007fff81b369aa __select + 10
1   libglib-2.0.0.dylib           	0x000000010967e2ab g_poll + 399
2   libglib-2.0.0.dylib           	0x00000001096727ae g_main_context_iterate + 335
3   libglib-2.0.0.dylib           	0x0000000109672854 g_main_context_iteration + 55
4   libglib-2.0.0.dylib           	0x0000000109673922 glib_worker_main + 53
5   libglib-2.0.0.dylib           	0x0000000109692f40 g_thread_proxy + 90
6   libsystem_pthread.dylib       	0x00007fff8e8b8899 _pthread_body + 138
7   libsystem_pthread.dylib       	0x00007fff8e8b872a _pthread_start + 137
8   libsystem_pthread.dylib       	0x00007fff8e8bcfc9 thread_start + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x3faeb851eb851eb8  rbx: 0x000000000be204a8  rcx: 0x3faeb851eb851eb8  rdx: 0x00007fff5781bab8
  rdi: 0x000000000be204a8  rsi: 0x00007fff5781bb60  rbp: 0x00007fff5781bad0  rsp: 0x00007fff5781bac0
   r8: 0x0000000000000001   r9: 0x00007fab0bf00000  r10: 0x00007fff5781bb30  r11: 0x00007faa00ceb4b4
  r12: 0x00007fff5781bb30  r13: 0x0000000000000008  r14: 0x00007fff73136420  r15: 0x00007fff73136420
  rip: 0x0000000109a6495d  rfl: 0x0000000000010202  cr2: 0x000000000be204d8
  
Logical CPU:     0
Error Code:      0x00000004
Trap Number:     14

Is this the same problem as before, but showing up in the viewer dynamic library?

comment:21 by Adam Dershowitz <dersh@…>, 10 years ago

Looks like libproc3d.dylib is provided by openmodelica-devel, which I hadn't updated. I am going to update that now, and see if the fix that you did will propagate to this library.

comment:22 by Adam Dershowitz <dersh@…>, 10 years ago

Nope. I upgraded openmodelica-devel, hoping that it would upgrade libproc3d.dylib, and include the repaired header files. But that didn't seem to change anything.
So dbus-server.py segmentation faults whenever I run the sim.

comment:23 by Martin Sjölund, 10 years ago

Might work in r21848 (pulls in https://github.com/OpenModelica/modelica3d/commit/4183b683c7d064ea8bc32f0f30a984e3cdb87e98). I got a segmentation fault somewhere because it couldn't create a GUI windows (I don't have any GUI, so that is to be expected).

Version 0, edited 10 years ago by Martin Sjölund (next)

comment:24 by Adam Dershowitz <dersh@…>, 10 years ago

Success!
For the first time I have 3d graphics working.

As always, thanks so much.

comment:25 by Martin Sjölund, 10 years ago

Component: UnknownThird-Party Libraries
Owner: changed from somebody to Martin Sjölund
Status: newassigned

comment:26 by Martin Sjölund, 10 years ago

Resolution: fixed
Status: assignedclosed
Summary: Mac openmodelica-devel fails to buildSupport Modelica3D on Mac
Note: See TracTickets for help on using tickets.