Project

General

Profile

Problems with Auth::Widget

Added by Miguel Revilla about 11 years ago

I'm implementing an auth system based on Wt::Auth, but every time that I try to use an AuthWidget I get a segfault. I have a minimum example that doesn't work. What's wrong with this code? Thanks!

#include <Wt/WApplication>
#include <Wt/WEnvironment>
#include <Wt/WServer>
#include <Wt/WVBoxLayout>
#include <Wt/WText>
#include <Wt/WContainerWidget>
#include <Wt/Auth/AuthWidget>
#include <Wt/Auth/Login>
#include <Wt/Auth/User>

using namespace Wt ;

class logintest : public WApplication {
public:
        logintest(const WEnvironment &env) ;

private:
        void loginChange() ;
} ;

WApplication *createLoginTest(const WEnvironment &env) ;

int main(int argc, char **argv) {

        Wt::WServer server(argv[0]) ;
        server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION) ;
        server.addEntryPoint(Wt::Application, createLoginTest, "/", "icons/favicon.png") ;

        if(server.start()) {                                                                                                                         
                Wt::WServer::waitForShutdown() ;
                server.stop() ;
        }
}

logintest::logintest(const WEnvironment &env) : WApplication(env) {

        WVBoxLayout *mainLayout = new WVBoxLayout() ;
        mainLayout->addWidget(new WText("Login widget test")) ;

        Auth::User *authU = new Auth::User() ;
        Auth::Login *authL = new Auth::Login() ;
        authL->changed().connect(this,&logintest::loginChange) ;
        authL->login(*authU,Auth::LoggedOut) ;
        Auth::AuthWidget *authW = new Auth::AuthWidget(*authL) ;

        mainLayout->addWidget(authW) ;

        root()->setLayout(mainLayout) ;

}

void logintest::loginChange() {

}

WApplication *createLoginTest(const WEnvironment &env) {
        return new logintest(env) ;
}

Replies (3)

RE: Problems with Auth::Widget - Added by Miguel Revilla about 11 years ago

A different segfault (with slightly different code), gdb output:

#0  0x00007ffff5a682a3 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) ()
   from /usr/lib/libstdc++.so.6
#1  0x00007ffff74fa6e3 in Wt::Auth::AuthWidget::onLoginChange() () from /usr/lib/libwt.so.35
#2  0x00007ffff74fb1db in Wt::Auth::AuthWidget::create() () from /usr/lib/libwt.so.35
#3  0x00007ffff74f9fee in Wt::Auth::AuthWidget::render(Wt::WFlags<Wt::RenderFlag>) () from /usr/lib/libwt.so.35
#4  0x00007ffff74ec93b in Wt::WWidget::createSDomElement(Wt::WApplication*) () from /usr/lib/libwt.so.35
#5  0x00007ffff7321205 in Wt::StdWidgetItemImpl::createDomElement(bool, bool, Wt::WApplication*) () from /usr/lib/libwt.so.35
#6  0x00007ffff731b64d in Wt::StdGridLayoutImpl2::createElement(Wt::WLayoutItem*, Wt::WApplication*) () from /usr/lib/libwt.so.35
#7  0x00007ffff731df41 in Wt::StdGridLayoutImpl2::createDomElement(bool, bool, Wt::WApplication*) () from /usr/lib/libwt.so.35
#8  0x00007ffff731b64d in Wt::StdGridLayoutImpl2::createElement(Wt::WLayoutItem*, Wt::WApplication*) () from /usr/lib/libwt.so.35
#9  0x00007ffff731df41 in Wt::StdGridLayoutImpl2::createDomElement(bool, bool, Wt::WApplication*) () from /usr/lib/libwt.so.35
#10 0x00007ffff7397eeb in Wt::WContainerWidget::createDomChildren(Wt::DomElement&, Wt::WApplication*) () from /usr/lib/libwt.so.35
#11 0x00007ffff739a198 in Wt::WContainerWidget::createDomElement(Wt::WApplication*, bool) () from /usr/lib/libwt.so.35
#12 0x00007ffff74dccce in Wt::WWebWidget::createActualElement(Wt::WWidget*, Wt::WApplication*) () from /usr/lib/libwt.so.35
#13 0x00007ffff74ec955 in Wt::WWidget::createSDomElement(Wt::WApplication*) () from /usr/lib/libwt.so.35
#14 0x00007ffff7398200 in Wt::WContainerWidget::createDomChildren(Wt::DomElement&, Wt::WApplication*) () from /usr/lib/libwt.so.35
#15 0x00007ffff739a198 in Wt::WContainerWidget::createDomElement(Wt::WApplication*, bool) () from /usr/lib/libwt.so.35
#16 0x00007ffff74dccce in Wt::WWebWidget::createActualElement(Wt::WWidget*, Wt::WApplication*) () from /usr/lib/libwt.so.35
#17 0x00007ffff74ec955 in Wt::WWidget::createSDomElement(Wt::WApplication*) () from /usr/lib/libwt.so.35
#18 0x00007ffff75c9117 in Wt::WebRenderer::serveMainAjax(Wt::WStringStream&) () from /usr/lib/libwt.so.35
#19 0x00007ffff75ccc3d in Wt::WebRenderer::serveMainscript(Wt::WebResponse&) () from /usr/lib/libwt.so.35
#20 0x00007ffff75b6222 in Wt::WebSession::serveResponse(Wt::WebSession::Handler&) () from /usr/lib/libwt.so.35
#21 0x00007ffff75b9c6f in Wt::WebSession::render(Wt::WebSession::Handler&) () from /usr/lib/libwt.so.35
#22 0x00007ffff75bcb40 in Wt::WebSession::notify(Wt::WEvent const&) () from /usr/lib/libwt.so.35
#23 0x00007ffff75b7fba in Wt::WebSession::handleRequest(Wt::WebSession::Handler&) () from /usr/lib/libwt.so.35
#24 0x00007ffff75aabc8 in Wt::WebController::handleRequest(Wt::WebRequest*) () from /usr/lib/libwt.so.35
#25 0x00007ffff6f0119f in boost::asio::detail::completion_handler<boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*> > > >::do_complete(boost::asio::detail::task_io_service*, boost::asio::detail::task_io_service_operation*, boost::system::error_code const&, unsigned long) () from /usr/lib/libwthttp.so.35
#26 0x00007ffff73fb02f in boost::asio::detail::task_io_service::run(boost::system::error_code&) () from /usr/lib/libwt.so.35
#27 0x00007ffff73f712c in Wt::WIOService::run() () from /usr/lib/libwt.so.35
#28 0x00007ffff4ee0a09 in ?? () from /usr/lib/libboost_thread.so.1.53.0
#29 0x00007ffff2d8cdd2 in start_thread () from /usr/lib/libpthread.so.0
#30 0x00007ffff51d1c7d in clone () from /usr/lib/libc.so.6

Didn't mention in the previous post. I'm using lastest wt git version with gcc 4.8.0. Taking a look at the code of onLoginChange, I can't really figure out where std::basic_string (or anything mentioned in #0) is involved.

Cheers!

RE: Problems with Auth::Widget - Added by Miguel Revilla about 11 years ago

I figured it out and its working now. Thanks anyway.

RE: Problems with Auth::Widget - Added by Zalu Hobgobicus about 11 years ago

Hmm. I'm learning the Auth Widget this weekend too, but I haven't seen a segfault problem.

    (1-3/3)