Page 2 of 3

Re: Common build error

Posted: Mon Jan 14, 2013 7:21 pm
by georgido
Geoff the Medio wrote:or a logging issue... Does your Windows username have non-latin characters in it? Issues with them seemed to have been fixed a few months ago, but it's possble there are still issues.
when i was installing windows i had used a name with non-latin characters, but then i changed that to a latin-character one from the control panel... however i just created another user account and now it runs just fine... so i guess you were right...

Re: Common build error

Posted: Mon Jan 14, 2013 7:28 pm
by Geoff the Medio
georgido wrote:when i was installing windows i had used a name with non-latin characters, but then i changed that to a latin-character one from the control panel... however i just created another user account and now it runs just fine... so i guess you were right...
That's irritating. Can you try to hunt down where the crash is happening with your non-latin name? My guess is that the Ogre logger or the general FreeOrion logger (log4cpp) are not converting the UTF-8 or UTF-16 path strings properly. If you can step through the code or add some debugging lines to check how the pathes are being handled and identify where the crash happens, that would be useful.

Re: Common build error

Posted: Mon Jan 14, 2013 7:45 pm
by georgido

Code: Select all

void FileAppender::_append(const LoggingEvent& event) {
    std::string message(_getLayout().format(event));
    if (!::write(_fd, message.data(), message.length())) {
        // XXX help! help!
    }
}
the game crashes after reaching the if-statement... that's in FileAppender.cpp. had one cout before the if-block and one after it, but the one after was never reached...

Re: Common build error

Posted: Mon Jan 14, 2013 8:12 pm
by Geoff the Medio
Does it help if you modify CategoryStream::flush() in CategoryStream.cpp to be this:

Code: Select all

    void CategoryStream::flush() {
        try {
            if (_buffer) {
                getCategory().log(getPriority(), _buffer->str());
                delete _buffer;
                _buffer = NULL;
            }
        } catch (...) {
            // logging failed...
        }
    }
Probably a long shot, but maybe worth a try to wrap it in a try-cach block.

Re: Common build error

Posted: Mon Jan 14, 2013 8:19 pm
by georgido
Geoff the Medio wrote:Does it help if you modify CategoryStream::flush() in CategoryStream.cpp to be this:

Code: Select all

    void CategoryStream::flush() {
        try {
            if (_buffer) {
                getCategory().log(getPriority(), _buffer->str());
                delete _buffer;
                _buffer = NULL;
            }
        } catch (...) {
            // logging failed...
        }
    }
Probably a long shot, but maybe worth a try to wrap it in a try-cach block.
nope, still the same...

Re: Common build error

Posted: Mon Jan 14, 2013 8:20 pm
by Geoff the Medio
Can you modify this function with the cout line and tell me if / what is output on the console before the crash?

Code: Select all

    void FileAppender::_append(const LoggingEvent& event) {
        std::string message(_getLayout().format(event));
        std::cout << "_fd: " << _fd << std::endl;
        if (!::write(_fd, message.data(), message.length())) {
            // XXX help! help!
        }
    }
Edit: And may try putting

Code: Select all

        if (_fd == -1)
            return;
after the cout line.

Re: Common build error

Posted: Mon Jan 14, 2013 8:32 pm
by georgido
Geoff the Medio wrote:Can you modify this function with the cout line and tell me if / what is output on the console before the crash?

Code: Select all

    void FileAppender::_append(const LoggingEvent& event) {
        std::string message(_getLayout().format(event));
        std::cout << "_fd: " << _fd << std::endl;
        if (!::write(_fd, message.data(), message.length())) {
            // XXX help! help!
        }
    }
Edit: And may try putting

Code: Select all

        if (_fd == -1)
            return;
after the cout line.
it was indeed -1 and after putting the return statement the game runs normally... just to mention it, fd was printed more than one time, if that means anything...

Re: Common build error

Posted: Mon Jan 14, 2013 8:34 pm
by Geoff the Medio
georgido wrote:it was indeed -1 and after putting the return statement the game runs normally...
Except that you won't get any log files... except maybe ogre.log; does that get created?

This suggests it's unable to create the file for some reason, likely due to the log4cpp code not handling the non-latin pathes correctly, or not being fed them in a form it can use.
just to mention it, fd was printed more than one time, if that means anything...
It should print it out every time the game tries to write something to the log file.

Re: Common build error

Posted: Mon Jan 14, 2013 8:36 pm
by georgido
Geoff the Medio wrote:except maybe ogre.log; does that get created?
well aside from the empty freeorion file now there is a freeoriond file but no ogre.log

Re: Common build error

Posted: Mon Jan 14, 2013 8:38 pm
by Geoff the Medio
Does freeoriond.log contain anything?

If you felt like looking into the logger initialization and what the path string it gets sent is, that might be helpful. I don't have time at the moment to point you to the right place to look, though.

Re: Common build error

Posted: Mon Jan 14, 2013 8:41 pm
by georgido
Geoff the Medio wrote:Does freeoriond.log contain anything?

If you felt like looking into the logger initialization and what the path string it gets sent is, that might be helpful. I don't have time at the moment to point you to the right place to look, though.
there were two lines:
2013-01-14 22:30:22,028 DEBUG Server : (ServerFSM) Idle
2013-01-14 22:30:22,028 DEBUG Server : FreeOrion server waiting for network events

once i get more familiar with the code (actually first day looking at it) i guess i'll give it a look...

Re: Common build error

Posted: Mon Jan 14, 2013 9:23 pm
by Geoff the Medio
georgido wrote:
Geoff the Medio wrote:Does freeoriond.log contain anything?
there were two lines:
2013-01-14 22:30:22,028 DEBUG Server : (ServerFSM) Idle
2013-01-14 22:30:22,028 DEBUG Server : FreeOrion server waiting for network events
That's bizzare... Why would the client be unable to write to its log file, while the server can do so fine at almost the same file location?

Re: Common build error

Posted: Tue Jan 15, 2013 3:01 am
by Geoff the Medio
Looks like there is a bit of a difference in how the client and server log file pathes are set up. Could you try this patch to see if it gets the client log working with the non-latin username?

Re: Common build error

Posted: Tue Jan 15, 2013 11:10 am
by georgido
Geoff the Medio wrote:Looks like there is a bit of a difference in how the client and server log file pathes are set up. Could you try this patch to see if it gets the client log working with the non-latin username?
something's wrong with line 15 from the patch file...

std::ofstream : Error:type name not allowed
temp: Error:expected a ';'
also temp is considered undefined on line 16

Re: Common build error

Posted: Tue Jan 15, 2013 7:23 pm
by Geoff the Medio
georgido wrote:something's wrong with line 15 from the patch file...
Weird... It looks fine to me... I guess it didn't apply properly for you. Try manually replacing these lines of HumanClientApp.cpp (around line 194)...

Code: Select all

    boost::filesystem::path log_path = GetUserDir() / "freeorion.log";

    // erase old log
    boost::filesystem::ofstream temp(log_path);
    temp.close();

    std::string LOG_FILENAME = PathString(log_path);

    log4cpp::Appender* appender = new log4cpp::FileAppender("FileAppender", LOG_FILENAME);
with this

Code: Select all

    const std::string HUMAN_CLIENT_LOG_FILENAME((GetUserDir() / "freeorion.log").string());

    // a platform-independent way to erase the old log
    std::ofstream temp(HUMAN_CLIENT_LOG_FILENAME.c_str());
    temp.close();

    log4cpp::Appender* appender = new log4cpp::FileAppender("FileAppender", HUMAN_CLIENT_LOG_FILENAME);