CEF Proxy AuthCallback - segfault

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

CEF Proxy AuthCallback - segfault

Postby koudis » Fri Jul 07, 2017 6:02 am

Hello all :),

I have a problem with CefAuthCallback (from CefRequestHandler::GetAuthCerdentials).

I pass the CefAuthCallback pointer to the my class instance, retrieve proxy user and password through javascript and call auth_callback->Continue(...) --> I get segfault.

My workflow:
GetAuthCerdentials()
    - On GetAuthcerdentials I check if it's a proxy auth request, if NO return false, If YES just continue.
    - Save the AuthCallback pointer (to the own class instance)
    - Call frame->LoadURL("client://working_directory/pages/proxy.html")
      - proxy.html is a static web page which send user cerdentials througth Javascript async callback to the browser process.
      - async callback is registred before LoadURL is called (in stage "save the AuthCallback" --> the auth callback is part of class instance which is part of Callbac router which is responsible to solve JS async callbacks from browser --> auth_callback->Continue()|Cancel() is called from UI thread of Browser process).
    - return true

OnQuery (CefMessageRouterBrowserSide::Handler)
    - Receive callback from javascript
    - check if the callback has a route in the router
    - pick up the callback from the router
    - call the callback (the callback contains auth_callback pointer which was pass in GetAuthCerdentials())
    - call auth_callback->Continue() (or any other action like auth_callback = nullptr) --> segfault

I am using CEF in verison 3.3071.1646.gbb29707 (but it happends in any other CEF so I think it's not a bug...)

I really do not know what i am doing wrong? Can anyone help me please :).

Thanks,
John
koudis
Techie
 
Posts: 21
Joined: Fri Jul 07, 2017 4:30 am

Re: CEF Proxy AuthCallback - segfault

Postby magreenblatt » Fri Jul 07, 2017 12:26 pm

Are you keeping the CefAuthCallback in a CefRefPtr? Are you navigating in the same frame with the pending auth request?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: CEF Proxy AuthCallback - segfault

Postby koudis » Fri Jul 07, 2017 6:25 pm

Hello,

Are you keeping the CefAuthCallback in a CefRefPtr?

Yes I am keepeng the AuthCallback in a CefRefPtr.

Are you navigating in the same frame with the pending auth request?

I am not understand this. In GetAuthCerdentials I get a 'frame'. On this frame I call frame->LoadURL(<url>) and web site represented by <url> stay in this frame (no other windows, frames, navigating back or forward...).
(But the url (client://<my_nice_path>) is handled by my own scheme handler).


Thanks :),
John
koudis
Techie
 
Posts: 21
Joined: Fri Jul 07, 2017 4:30 am

Re: CEF Proxy AuthCallback - segfault

Postby koudis » Fri Jul 07, 2017 6:30 pm

There is a full fragment in GetAuthCerdentials

Code: Select all
bool RequestHandler::GetAuthCredentials(CefRefPtr<CefBrowser> browser,
         CefRefPtr<CefFrame> frame,
         bool is_proxy,
         const CefString& host,
         int port,
         const CefString& realm,
         const CefString& scheme,
         CefRefPtr<CefAuthCallback> callback) {
      using namespace callback;
      LIB_LOG_DEBUG("GetAuthCredentials");
      if(!is_proxy)
         return false;

      std::string return_url;
      if(session != nullptr)
         return_url = session->config.url;
      else
         return_url = frame->GetURL();

      std::unique_lock<std::mutex> lock(router->get_mutex());
      std::shared_ptr<v8::RouterCallback> router_callback =
         router->find(ProxyCallback::route);
      if(router_callback != nullptr) {
         if(proxy_callback != router_callback)
            proxy_callback = nullptr;
      }

      if(proxy_callback == nullptr) {
         const std::string str_port = std::to_string(port);
         proxy_callback = std::make_shared<ProxyCallback>(return_url,
               host.ToString(), str_port, scheme.ToString());
         router->add(ProxyCallback::route, proxy_callback);
      }
      proxy_callback->set_auth_callback(callback);
      lock.unlock();

      frame->LoadURL("client:///resources/pages/proxy.html");
      return true;
   }
koudis
Techie
 
Posts: 21
Joined: Fri Jul 07, 2017 4:30 am

Re: CEF Proxy AuthCallback - segfault

Postby magreenblatt » Fri Jul 07, 2017 7:31 pm

By navigating in the same frame while the proxy request is pending you may be invalidating the callback object. You should instead use a separate CefBrowser instance to display your password entry form. You can also file a bug about the crash that you're experiencing.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: CEF Proxy AuthCallback - segfault

Postby koudis » Thu Jul 13, 2017 1:53 am

Hello :),

thanks for your reply! It works!

If I spawn a new browser, everything works :).


John
koudis
Techie
 
Posts: 21
Joined: Fri Jul 07, 2017 4:30 am


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 17 guests