[Solved]Deadlock at startup on iPad2

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
SAM_tak
Gnoblar
Posts: 17
Joined: Wed May 25, 2011 5:17 pm

[Solved]Deadlock at startup on iPad2

Post by SAM_tak »

Hi All.

I'm trying to use GLES2 Renderer for iOS of OGRE 1.8.0.
I create a new project file based on XCode template (for 1.7.3) and modified it referencing SampleBrowser's code,
build succeeded, and it had run!
(some topics of this forum help me. Thanks!)

but my program often stall at startup.

stall point is not fixed. but typical point is "mWorkQueue->startup();" in Ogre::Root::oneTimePostWindowInit()

Code: Select all

#0	0x3525fd18 in __semwait_signal ()
#1	0x344db4b2 in nanosleep ()
#2	0x003db0f4 in boost::shared_ptr<boost::detail::thread_data_base> boost::thread::make_thread_info<Ogre::DefaultWorkQueueBase::WorkerFunc>(Ogre::DefaultWorkQueueBase::WorkerFunc) at /Users/takasugiosamu/XCodeProjects/ogre/iosbuild/iPhoneDependencies/include/boost/smart_ptr/detail/yield_k.hpp:123
#3	0x003d75dc in Ogre::DefaultWorkQueue::startup(bool) ()
#4	0x002623fc in Ogre::Root::oneTimePostWindowInit() ()
#5	0x00267ad4 in Ogre::Root::initialise(bool, std::string const&, std::string const&) ()
#6	0x00005270 in OgreFramework::initOgre(std::string, OIS::KeyListener*, OIS::MultiTouchListener*) ()
#7	0x00003b9a in DemoApp::startDemo() ()
#8	0x0000309c in -[AppDelegate go] ()
#9	0x000034cc in -[AppDelegate application:didFinishLaunchingWithOptions:] ()
#10	0x33051820 in -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] ()
#11	0x3304bb64 in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] ()
#12	0x330207d6 in -[UIApplication handleEvent:withNewEvent:] ()
#13	0x33020214 in -[UIApplication sendEvent:] ()
#14	0x3301fc52 in _UIApplicationHandleEvent ()
#15	0x34e19e76 in PurpleEventCallback ()
#16	0x33ab9a96 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#17	0x33abb83e in __CFRunLoopDoSource1 ()
#18	0x33abc60c in __CFRunLoopRun ()
#19	0x33a4cec2 in CFRunLoopRunSpecific ()
#20	0x33a4cdca in CFRunLoopRunInMode ()
#21	0x3304ad48 in -[UIApplication _run] ()
#22	0x33048806 in UIApplicationMain ()
#23	0x00003778 in main ()
In other time, stall at "mMaterialManager = OGRE_NEW MaterialManager();" in Ogre::Root::Root() (constructor)

it seems boost::shared_ptr rise deadlock, but I can't avoid this deadlock yet.

Can anyone figure out how to avoid this deadlock?

SampleBrowser with GLES2/1.8.0 works well in my environment. but my application dosen't work same as SampleBrowser...
Last edited by SAM_tak on Wed Jul 27, 2011 11:29 pm, edited 1 time in total.
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Deadlock at startup on iPad2

Post by masterfalcon »

Maybe some of the code for your app setup would be a great help. Since we don't know what you're doing differently it makes it difficult to help.
SAM_tak
Gnoblar
Posts: 17
Joined: Wed May 25, 2011 5:17 pm

Re: Deadlock at startup on iPad2

Post by SAM_tak »

Thanks for your reply, masterfalcon.

I made minimum code set reproducing this symptom. Attached file is it.
This code set requires OgreSDK directory exists in same directory of .xcodeproj file.
Please make symbol link named 'OgreSDK' at directory included xcodeproj file.
> ln -s YourOgreSDKPath OgreSDK
And ogrehead.mesh and textures are too large to contain for attachment file,
copy these files to media directory from Xcode template for v1.7.3

The symptom not always happen, but it happens in less than 10 times.

Critical point is in 34th line of "mmdcontroller.hpp".
To comment out this line, this program not to stall.
class MMDController is just defined, not used...

Perhaps this is boost::shared_ptr/boost::thread issue instead of Ogre issue.
You do not have the required permissions to view the files attached to this post.
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Deadlock at startup on iPad2

Post by masterfalcon »

Thanks. I'll try to take a look tonight. I don't have an iPad 2 but maybe I can spot something in the code or reproduce on an iPad 1.
rado0x54
Gnoblar
Posts: 14
Joined: Fri Jul 08, 2011 5:38 pm
x 1

Re: Deadlock at startup on iPad2

Post by rado0x54 »

I also had a Deadlock problem. See few posts before. What boost version are you using?
SAM_tak
Gnoblar
Posts: 17
Joined: Wed May 25, 2011 5:17 pm

Re: Deadlock at startup on iPad2

Post by SAM_tak »

I'm using Ogre_iOS_4.3_Dependencies_20110411.dmg's boost.
boost version is unknown for me.

I may have to build by source of latest boost. i'll try and report it later.
SAM_tak
Gnoblar
Posts: 17
Joined: Wed May 25, 2011 5:17 pm

Re: Deadlock at startup on iPad2

Post by SAM_tak »

Oh, Thank you, rad0x54.
your post seems help me!
http://www.ogre3d.org/forums/viewtopic. ... 25#p433425
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Deadlock at startup on iPad2

Post by masterfalcon »

If I'm reading all of this right, we can fix/workaround this issue by adding the defines when building Ogre? It doesn't sound like Boost needs to be rebuilt, is that correct?
rado0x54
Gnoblar
Posts: 14
Joined: Fri Jul 08, 2011 5:38 pm
x 1

Re: Deadlock at startup on iPad2

Post by rado0x54 »

Hey,

compiling with pThread Flags should definitely work, however pthreads are generally much slower then a native (processor-dependent) locking mechanism. I'm actually not sure if both, Ogre and Boost have to be recompiled with that flag or if only Ogre would work as well. If boost cpp files themselves do not use smart_ptr and threads (I assume they DO), it would be sufficient to only compile Ogre with these flags.

However, I have a setup working right now, without pthreads and boost 1.47 on the iPad2, but I cannot absolutely explain why it works now.

@Sam_tak: Please try to recompile Ogre with boost 1.47 and include these references in your project.

I posted the date_time and thread library here (link is only temporary):
http://dl.dropbox.com/u/319357/Sharing/ ... thread.zip

I also created an Apple Framework for boost (this includes all headers and all libraries that could be compiled for arm).
http://dl.dropbox.com/u/319357/Sharing/ ... mework.zip

Please copy the Headers out from this directory and replace them in your iPhoneDependecies dir (along with the libs) and recompile Ogre. Afterwards, you can remove all references to boost (eg lboost_thread) from the project properties and just drag and drop the framework into your Xcode Project. You can conveniently use this framework for all your other boost - iPhone Projects. Just drag and drop. It includes the following boost libs:

libboost_chrono.a libboost_random.a
libboost_date_time.a libboost_regex.a
libboost_exception.a libboost_serialization.a
libboost_filesystem.a libboost_signals.a
libboost_graph.a libboost_system.a
libboost_iostreams.a libboost_thread.a
libboost_program_options.a libboost_wserialization.a

Or you can keep the old structure of course and don't use "boost.framework" at all.

Report back if that solves the spinlock. (Again do not use the PThread defines for that.)
rado.
User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
x 10

Re: Deadlock at startup on iPad2

Post by DanielSefton »

rado0x54 wrote:I posted the date_time and thread library here (link is only temporary):
Dude, you are awesome because I just tried to run my project on the simulator and I got the following error:
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
pthread_cond_init$UNIX2003 called from function _ZN5boost12_GLOBAL__N_125make_external_thread_dataEv in image [redacted].
If you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first.
I knew I needed to recompile boost, but I came across this thread and replaced my libs with yours and it worked. How convenient :)
rado0x54
Gnoblar
Posts: 14
Joined: Fri Jul 08, 2011 5:38 pm
x 1

Re: Deadlock at startup on iPad2

Post by rado0x54 »

Well, I find the framework even more convenient. :) No more linker flags...
If you use the 1.47 libs, I would strongly suggest rebuilding Ogre with the 1.47 headers. Otherwise you could have strange things happening.
User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
x 10

Re: Deadlock at startup on iPad2

Post by DanielSefton »

rado0x54 wrote:Well, I find the framework even more convenient. :) No more linker flags...
If you use the 1.47 libs, I would strongly suggest rebuilding Ogre with the 1.47 headers. Otherwise you could have strange things happening.
Yeah, although that error was only on the simulator so it doesn't matter too much. Which iOS version did you compile them against? 4.3? And did you lipo them for different architectures?
rado0x54
Gnoblar
Posts: 14
Joined: Fri Jul 08, 2011 5:38 pm
x 1

Re: Deadlock at startup on iPad2

Post by rado0x54 »

Yeah,

Code: Select all

otool -hv libboost_*.a
should tell you armv6/7/i386. Yes, compiled against SDK4.3.

I assume you link against the 1.47 libs for the device as well. I would recompile.
SAM_tak
Gnoblar
Posts: 17
Joined: Wed May 25, 2011 5:17 pm

Re: [Solved]Deadlock at startup on iPad2

Post by SAM_tak »

I rebuilt Ogre and boost with BOOST_AC_USE_PTHREADS & BOOST_SP_USE_PTHREADS flags,
My program had worked!

Thanks, rado0x54, masterfalcon.