FATAL assertion in thread_restrictions.cc

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

FATAL assertion in thread_restrictions.cc

Postby robs » Wed Jun 05, 2013 2:54 pm

Hello,

I'm just getting started with CEF. I've successfully built and run cefclient on Windows 7 using VS2012 via the binary distribution 3.1453.1255.

Next, I tried integrating the cefclient files into my application, attempting to change as little as possible to just make it load a page within my application environment. I can see that CefInitialize() is called. CefBrowserHost::CreateBrowser() is called. And eventually it calls CefRunMessageLoop(). Then it breaks into an assertion.

The debugger output window shows:
Code: Select all
[0605/154337:FATAL:thread_restrictions.cc(38)] Function marked as IO-only was called from a thread that disallows IO!  If this thread really should be allowed to make IO calls, adjust the call to base::ThreadRestrictions::SetIOAllowed() in this thread's startup.

The thread that is running appears to be the main thread. The call stack is pasted below.

I've searched for this error but come up empty. Thanks in advance for any suggestions for what might be causing this!

Rob

Code: Select all
    libcef.dll!base::debug::BreakDebugger() Line 107   C++
    libcef.dll!logging::LogMessage::~LogMessage() Line 650   C++
    libcef.dll!base::ThreadRestrictions::AssertIOAllowed() Line 45   C++
    libcef.dll!file_util::AbsolutePath(base::FilePath * path=0x01e7cc34) Line 43   C++
    libcef.dll!PathService::Get(int key=5, base::FilePath * result=0x01e7d1e8) Line 220   C++
    libcef.dll!content::PathProvider(int key=4000, base::FilePath * result=0x01e7d1e8) Line 16   C++
    libcef.dll!PathService::Get(int key=4000, base::FilePath * result=0x01e7d280) Line 209   C++
    libcef.dll!content::ChildProcessHost::GetChildPath(int flags=0) Line 107   C++
    libcef.dll!content::RenderProcessHostImpl::Init() Line 460   C++
    libcef.dll!content::RenderViewHostImpl::CreateRenderView(const std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > & frame_name={...}, int opener_route_id=-2, int max_page_id=-1) Line 234   C++
    libcef.dll!content::WebContentsImpl::CreateRenderViewForRenderManager(content::RenderViewHost * render_view_host=0x03ee4f80, int opener_route_id=-2) Line 3391   C++
    libcef.dll!content::RenderViewHostManager::InitRenderView(content::RenderViewHost * render_view_host=0x03ee4f80, int opener_route_id=-2) Line 690   C++
    libcef.dll!content::RenderViewHostManager::Navigate(const content::NavigationEntryImpl & entry={...}) Line 140   C++
    libcef.dll!content::WebContentsImpl::NavigateToEntry(const content::NavigationEntryImpl & entry={...}, content::NavigationController::ReloadType reload_type=NO_RELOAD) Line 1659   C++
    libcef.dll!content::WebContentsImpl::NavigateToPendingEntry(content::NavigationController::ReloadType reload_type=NO_RELOAD) Line 1627   C++
    libcef.dll!content::NavigationControllerImpl::NavigateToPendingEntry(content::NavigationController::ReloadType reload_type=NO_RELOAD) Line 1666   C++
    libcef.dll!content::NavigationControllerImpl::LoadEntry(content::NavigationEntryImpl * entry=0x03ee3d80) Line 402   C++
    libcef.dll!content::NavigationControllerImpl::LoadURLWithParams(const content::NavigationController::LoadURLParams & params={...}) Line 826   C++
    libcef.dll!content::NavigationControllerImpl::LoadURL(const GURL & url={...}, const content::Referrer & referrer={...}, content::PageTransition transition=PAGE_TRANSITION_TYPED, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & extra_headers={...}) Line 744   C++
    libcef.dll!CefBrowserHostImpl::LoadURL(__int64 frame_id=-1, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & url={...}) Line 1267   C++
    libcef.dll!CefBrowserHost::CreateBrowserSync(const CefWindowInfo & windowInfo={...}, CefRefPtr<CefClient> client={...}, const CefStringBase<CefStringTraitsUTF16> & url={...}, const CefStructBase<CefBrowserSettingsTraits> & settings={...}) Line 311   C++
    libcef.dll!`anonymous namespace'::CreateBrowserWithHelper(`anonymous-namespace'::CreateBrowserHelper * helper=0x03ef7c80) Line 76   C++
    libcef.dll!base::internal::RunnableAdapter<void (__cdecl*)(`anonymous namespace'::CreateBrowserHelper *)>::Run(`anonymous-namespace'::CreateBrowserHelper * const & a1=0x03ef7c80) Line 171   C++
    libcef.dll!base::internal::InvokeHelper<0,void,base::internal::RunnableAdapter<void (__cdecl*)(`anonymous namespace'::CreateBrowserHelper *)>,void __cdecl(`anonymous namespace'::CreateBrowserHelper * const &)>::MakeItSo(base::internal::RunnableAdapter<void (__cdecl*)(`anonymous namespace'::CreateBrowserHelper *)> runnable={...}, `anonymous-namespace'::CreateBrowserHelper * const & a1=0x03ef7c80) Line 872   C++
    libcef.dll!base::internal::Invoker<1,base::internal::BindState<base::internal::RunnableAdapter<void (__cdecl*)(`anonymous namespace'::CreateBrowserHelper *)>,void __cdecl(`anonymous namespace'::CreateBrowserHelper *),void __cdecl(`anonymous namespace'::CreateBrowserHelper *)>,void __cdecl(`anonymous namespace'::CreateBrowserHelper *)>::Run(base::internal::BindStateBase * base=0x03f56e80) Line 1173   C++
    libcef.dll!base::Callback<void __cdecl(void)>::Run() Line 396   C++
    libcef.dll!MessageLoop::RunTask(const base::PendingTask & pending_task={...}) Line 478   C++
    libcef.dll!MessageLoop::DeferOrRunPendingTask(const base::PendingTask & pending_task={...}) Line 491   C++
    libcef.dll!MessageLoop::DoWork() Line 671   C++
    libcef.dll!base::MessagePumpForUI::DoRunLoop() Line 241   C++
    libcef.dll!base::MessagePumpWin::RunWithDispatcher(base::MessagePump::Delegate * delegate=0x03ef7dc0, base::MessagePumpDispatcher * dispatcher=0x00000000) Line 64   C++
    libcef.dll!base::MessagePumpWin::Run(base::MessagePump::Delegate * delegate=0x03ef7dc0) Line 48   C++
    libcef.dll!MessageLoop::RunInternal() Line 433   C++
    libcef.dll!MessageLoop::RunHandler() Line 407   C++
    libcef.dll!base::RunLoop::Run() Line 46   C++
    libcef.dll!MessageLoop::Run() Line 314   C++
    libcef.dll!CefBrowserMessageLoop::RunMessageLoop() Line 28   C++
    libcef.dll!CefRunMessageLoop() Line 145   C++
    libcef.dll!cef_run_message_loop() Line 259   C++
   MyCefTest.exe!CefRunMessageLoop() Line 250   C++
robs
Mentor
 
Posts: 70
Joined: Wed Jun 05, 2013 2:22 pm

Re: FATAL assertion in thread_restrictions.cc

Postby magreenblatt » Wed Jun 05, 2013 4:38 pm

Try calling CefRunMessageLoop() before CreateBrowser(). You can use CefPostTask() to execute a task on the UI thread after the message loop has started.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: FATAL assertion in thread_restrictions.cc

Postby robs » Thu Jun 06, 2013 10:55 am

Thanks for the suggestion. That didn't help but after some more digging I found the problem!

Basically, there is a problem when trying to launch the render process. The debugger showed me that it was stopped here:

Code: Select all
    libcef.dll!base::ThreadRestrictions::AssertIOAllowed() Line 45   C++
>   libcef.dll!file_util::AbsolutePath(base::FilePath * path=0x0018cee0) Line 43   C++
    libcef.dll!PathService::Get(int key=5, base::FilePath * result=0x0018d494) Line 220   C++
    libcef.dll!content::PathProvider(int key=4000, base::FilePath * result=0x0018d494) Line 16   C++
    libcef.dll!PathService::Get(int key=4000, base::FilePath * result=0x0018d52c) Line 209   C++
    libcef.dll!content::ChildProcessHost::GetChildPath(int flags=0) Line 107   C++
    libcef.dll!content::RenderProcessHostImpl::Init() Line 460   C++


And the debugger also showed me that the path that was given to "file_util::AbsolutePath" had two dots in it (referencing a parent folder). This was due to the way my Visual Studio project was set up. I suppose that chromium uses GetModuleFileName to get the path to the parent process but this function gives the filename as it was used to launch the process, even if it has dots in it, etc. So, in this case when the file name isn't properly formed I guess it calls file_util::AbsolutePath() which then dies due to the restrictions.

You can reproduce this in cefclient by launching it from the command prompt. If the cefclient binary dist was put in a folder called "c:\cef" then this would cause the crash:
c:\cef\Release\..\out\Debug\cefclient.exe

I can move on by fixing my Visual Studio project but maybe there is something here worth fixing.

Thanks again,
Rob
robs
Mentor
 
Posts: 70
Joined: Wed Jun 05, 2013 2:22 pm

Re: FATAL assertion in thread_restrictions.cc

Postby magreenblatt » Thu Jun 06, 2013 11:53 am

robs wrote:You can reproduce this in cefclient by launching it from the command prompt. If the cefclient binary dist was put in a folder called "c:\cef" then this would cause the crash:
c:\cef\Release\..\out\Debug\cefclient.exe

What version of Visual Studio are you using? Did you try with the client binary distribution from the downloads page? I tried this with both debug and release builds on Windows 7 and was unable to reproduce the problem.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: FATAL assertion in thread_restrictions.cc

Postby robs » Thu Jun 06, 2013 1:11 pm

I'm using Visual Studio 2012.

Here is what I just did which allowed me to reproduce again:
1. open cefclient project in Visual Studio
2. open cefclient project properties (i.e. right click on cefclient in solution explorer and choose properties)
3. go to the debugging tab and change the value for the Command from the default of $(TargetPath) to something like this (but of course change based on your path):
C:\Users\rob\Documents\cef_binary_3.1453.1255_windows\Release\..\out\Debug\cefclient.exe
4. press F5 to start debugging
5. should break into debugger with assertion

Hope that works for you!

Thanks,
Rob
robs
Mentor
 
Posts: 70
Joined: Wed Jun 05, 2013 2:22 pm

Re: FATAL assertion in thread_restrictions.cc

Postby magreenblatt » Thu Jun 06, 2013 4:53 pm

I can reproduce the problem when using Visual Studio as you describe but not from the command prompt. It's an interesting problem, but probably not worth solving if it's only an issue when debugging with Visual Studio.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: FATAL assertion in thread_restrictions.cc

Postby robs » Thu Jun 06, 2013 7:53 pm

Funny, I remember reproducing with the command prompt before but now I cannot. I agree that it doesn't seem worth fixing. At least now that I understand what is happening there is an easy workaround.
robs
Mentor
 
Posts: 70
Joined: Wed Jun 05, 2013 2:22 pm

Re: FATAL assertion in thread_restrictions.cc

Postby junky » Wed Jul 03, 2013 11:50 am

Hi, I'm having the same problem with visual studio 2012.
Like you, I first did a bare bones application with the binary distribution sln project (and worked), Now I'm trying to moved it to a new project but I'm having the same fatal error as you.
How did you solve the problem?

Thankyou
junky
Newbie
 
Posts: 3
Joined: Wed Jul 03, 2013 11:45 am

Re: FATAL assertion in thread_restrictions.cc

Postby robs » Fri Jul 05, 2013 12:16 pm

The problem I was having was due to the ".." in the path as provided by Visual Studio. Two possible fixes:
1. On your project settings put an explicit absolute path to your executable. This way the path won't have any funny business in it from expanded variables, etc.
2. Just launch your executable manually from explorer and then attach the debugger.

Good luck!

Rob
robs
Mentor
 
Posts: 70
Joined: Wed Jun 05, 2013 2:22 pm

Re: FATAL assertion in thread_restrictions.cc

Postby junky » Sat Jul 06, 2013 5:51 pm

Thank you, it works!

But I can't understand yet why it's happening. It's a problem with libcef_dll_wrapper.lib?
junky
Newbie
 
Posts: 3
Joined: Wed Jul 03, 2013 11:45 am

Next

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 196 guests