logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
1.69 Crash after load - std::length_error
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development
View previous topic :: View next topic  
Author Message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Mon Aug 11, 2008 20:32    Post subject: Reply with quote

Please check your nwnx2.ini file, and see if your database configuration section is named [ODBC] or [Database]. If it's named [ODBC], please try renaming it to [Database].

The next thing to try would be do do a fresh recompile, but when you do that, after you run 'sh configure' and before you run 'make', please edit the Makefile and add '-g' to the CPPFLAGS before $(DEFS), to add debugging info, then try using GDB again on the core dump. Also, please do the 'list' command in GDB after you do the 'back' for backtrace.

Thanks,
Acaos
Back to top
View user's profile Send private message
weldieran



Joined: 05 Aug 2005
Posts: 71

PostPosted: Mon Aug 11, 2008 20:42    Post subject: Reply with quote

acaos wrote:
Please check your nwnx2.ini file, and see if your database configuration section is named [ODBC] or [Database]. If it's named [ODBC], please try renaming it to [Database].

The next thing to try would be do do a fresh recompile, but when you do that, after you run 'sh configure' and before you run 'make', please edit the Makefile and add '-g' to the CPPFLAGS before $(DEFS), to add debugging info, then try using GDB again on the core dump. Also, please do the 'list' command in GDB after you do the 'back' for backtrace.

Thanks,
Acaos


Oh how ridiculous! The one thing I didn't update was my nwnx2.ini file after compiling the trunk. I was using the nwnx2.ini from the nwnx_easy installation - which uses [ODBC2] section. Once i updated nwnx2.ini, no more crash Rolling Eyes sorry to waste your time!


Now, all that is left are those custom functions integration, I'll give it another swing to make them work. One question though, my functions use strncpy but i notice all of yours use memcpy - should I do the same?

I'm a programmer, yes, but C is not a strength of mine at all.

Thanks so much acaos!
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Mon Aug 11, 2008 20:50    Post subject: Reply with quote

It depends on what you're copying - for strings, I'd use strncpy(), for binary data (e.g. a structure), I'd use memcpy().

Glad to hear the problem is fixed! I'll definitely have to update the database plugin to not crash when there's a configuration problem.

Acaos
Back to top
View user's profile Send private message
weldieran



Joined: 05 Aug 2005
Posts: 71

PostPosted: Mon Aug 11, 2008 21:18    Post subject: Reply with quote

acaos wrote:
It depends on what you're copying - for strings, I'd use strncpy(), for binary data (e.g. a structure), I'd use memcpy().

Glad to hear the problem is fixed! I'll definitely have to update the database plugin to not crash when there's a configuration problem.

Acaos



K, great, now...

I know I am modifying NWNXmysql.cpp to add the call hooks.

But am I working with dbmysql.h/cpp or data.h/cpp to add the actual DB object function calls?

My guess is dbmysql.h/cpp. But then, what is data.h/cpp all about?
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Mon Aug 11, 2008 21:25    Post subject: Reply with quote

It looks like data.h and data.cpp aren't actually used for anything. The functions in there are never called that I can see. I haven't done very much work on the DB plugin at all (only bugfixes pretty much). Virusman might be able to say more when he returns from vacation.

Acaos
Back to top
View user's profile Send private message
weldieran



Joined: 05 Aug 2005
Posts: 71

PostPosted: Mon Aug 11, 2008 21:39    Post subject: Reply with quote

yea, looked like an unfinished script...

OK - so i get my functions in place and end up with:

ERROR: dlopen: ./nwnx_odbc.so: ./nwnx_odbc.so: undefined symbol: _ZTV4Data


What in gods name is ZTV4Data lol, only grep match is in the binary.

Any advise on debugging the cause of this?


[edit]
AGH! I've just realized the plugins folder there contains both a "db" folder and an ODMBC. Not even sure which one I should be working with.

[edit again]
Actually, looks like "odmbc" plugin conflicts with the "db" plugin. Both of them seek to produce nwnx_odbc.so
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Mon Aug 11, 2008 23:49    Post subject: Reply with quote

ODMBC is used for PostgreSQL and SQLite I believe. I have never used it; we use the DB version of ODBC on Higher Ground, as that is the one which supports MySQL.

Acaos
Back to top
View user's profile Send private message
weldieran



Joined: 05 Aug 2005
Posts: 71

PostPosted: Tue Aug 12, 2008 0:12    Post subject: Reply with quote

acaos wrote:
ODMBC is used for PostgreSQL and SQLite I believe. I have never used it; we use the DB version of ODBC on Higher Ground, as that is the one which supports MySQL.

Acaos


Looks like ODMBC has that hook for storing objects tho, thats nice

Well, as it turns out, I use that svn checkout trunk plus my old nwnx_odbc.so and everything runs perfectly fine so far.

Odd though, if I get rid of all the other plugins (as i only really use odbc/hashset), the system crashes with segfault. Can't quite figure that one out...

Quote:

# gdb nwserver core.6134
GNU gdb Red Hat Linux (6.5-8.fc6rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".


warning: Can't read pathname for load map: Input/output error.
Reading symbols from /home/user/nwn/nwnx2.so...done.
Loaded symbols for ./nwnx2.so
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libpthread.so.0...done.
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /usr/lib/libstdc++.so.6...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /home/user/nwn/nwnx_odbc.so...done.
Loaded symbols for ./nwnx_odbc.so
Reading symbols from /usr/lib/mysql/libmysqlclient.so.15...done.
Loaded symbols for /usr/lib/mysql/libmysqlclient.so.15
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libssl.so.6...done.
Loaded symbols for /lib/libssl.so.6
Reading symbols from /lib/libcrypto.so.6...done.
Loaded symbols for /lib/libcrypto.so.6
Reading symbols from /usr/lib/libgssapi_krb5.so.2...done.
Loaded symbols for /usr/lib/libgssapi_krb5.so.2
Reading symbols from /usr/lib/libkrb5.so.3...done.
Loaded symbols for /usr/lib/libkrb5.so.3
Reading symbols from /lib/libcom_err.so.2...done.
Loaded symbols for /lib/libcom_err.so.2
Reading symbols from /usr/lib/libk5crypto.so.3...done.
Loaded symbols for /usr/lib/libk5crypto.so.3
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /usr/lib/libkrb5support.so.0...done.
Loaded symbols for /usr/lib/libkrb5support.so.0
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /home/user/nwn/nwnx_hashset.so...done.
Loaded symbols for ./nwnx_hashset.so
Reading symbols from /lib/libnss_dns.so.2...done.
Loaded symbols for /lib/libnss_dns.so.2
Core was generated by `/home/user/nwn/nwserver -module test -maxclients 2 -pvp 1 -servervault 1 -e'.
Program terminated with signal 11, Segmentation fault.
#0 0x002fd231 in mysql_free_result () from /usr/lib/mysql/libmysqlclient.so.15
(gdb) back
#0 0x002fd231 in mysql_free_result () from /usr/lib/mysql/libmysqlclient.so.15
#1 0x00185970 in DbMySql::ProcessRequest () from ./nwnx_odbc.so
#2 0x00183ae4 in CNWNXmysql::OnRequest () from ./nwnx_odbc.so
#3 0x00164015 in StringPayLoad () from ./nwnx2.so
#4 0x001641f9 in my_SetString () from ./nwnx2.so
#5 0x082041ec in CNWVirtualMachineCommands::ExecuteCommandSetVar ()
#6 0x08231a7e in CNWVirtualMachineCommands::ExecuteCommand ()
#7 0x0826042e in CVirtualMachine::ExecuteCode ()
#8 0x082627d7 in CVirtualMachine::RunScriptFile ()
#9 0x082621d3 in CVirtualMachine::RunScript ()
#10 0x081b43ae in CNWSModule::EventHandler ()
#11 0x08096004 in CServerAIMaster::UpdateState ()
#12 0x080a0530 in CServerExoAppInternal::MainLoop ()
#13 0x0804bbe7 in main ()
(gdb) list
1 init.c: No such file or directory.
in init.c

Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Tue Aug 12, 2008 2:52    Post subject: Reply with quote

That particular crash is the one fixed by adding 'result = NULL' to the constructor.

Acaos
Back to top
View user's profile Send private message
weldieran



Joined: 05 Aug 2005
Posts: 71

PostPosted: Tue Aug 12, 2008 3:04    Post subject: Reply with quote

acaos wrote:
That particular crash is the one fixed by adding 'result = NULL' to the constructor.

Acaos


ahhh, i'll do that to our old nwnx_odbc then.

but it isn't odd that it works fine so long as it has all the other plugins running with it?
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Tue Aug 12, 2008 3:10    Post subject: Reply with quote

It's basically an uninitialized memory bug, so behavior can be randomly determined by what else is in memory.

Acaos
Back to top
View user's profile Send private message
weldieran



Joined: 05 Aug 2005
Posts: 71

PostPosted: Tue Aug 12, 2008 12:14    Post subject: Reply with quote

hmmmm

While all seems stable and functional - after awhile, I end up getting "DB went away" errors in the mysql log.

Db has not gone away of course, phpmyadmin still accesses it just fine.

These are simple queries


[edit]
I dont think mysql_ping is doing its job. Though I am not sure why it was never an issue before, mysql_ping behavior changed in version 5 of mysql. It no longer attempts to reconnect.

So I changed all mysql_ping lines in dbmysql.cpp to:

Code:

if( mysql_ping(&mysql)!=0 && !SqlConn() )


In hopes that'll stop the "db went away" errors.
Back to top
View user's profile Send private message
weldieran



Joined: 05 Aug 2005
Posts: 71

PostPosted: Tue Aug 12, 2008 14:20    Post subject: Reply with quote

I tried to find that result = null so I could move it over to our modified version of the db plugin... is this what you were talking about?

Code:

bool DbMySql::ProcessRequest (char *request, unsigned int responseSize)
{
        // if not connected try to reconnect
    if(connValid == ERR_NOTCONNECTED && !SqlConn()) {
                // SqlConn() will set the errorString for us
                return false;
        }

    // free the last results set
        if( result != NULL ) {
        mysql_free_result(result);
                result = NULL;
        }
               
    if(debugLevel==DBG_YES)
        fprintf(stream,"o Got request: %s\n", request);
    SqlExec (request, responseSize - 1);
        // if(error) printf("Error: %s\n", errorString);
    return !error;
}



If it is that result = null we're referring to, then my code already had it.

If that is the case, then I wonder what the seg fault crash is all about?
Back to top
View user's profile Send private message
acaos



Joined: 08 May 2007
Posts: 153

PostPosted: Tue Aug 12, 2008 17:49    Post subject: Reply with quote

No, it's this one:

Code:
DbMySql::DbMySql (ConnParam *p)
{
    error = false;
    connValid = ERR_NOTCONNECTED;
    debugLevel=DBG_NO;
    stream=stderr;
    result=NULL;
    SetConnParams(p);
}


Acaos
Back to top
View user's profile Send private message
weldieran



Joined: 05 Aug 2005
Posts: 71

PostPosted: Tue Aug 12, 2008 18:23    Post subject: Reply with quote

acaos wrote:
No, it's this one:

Code:
DbMySql::DbMySql (ConnParam *p)
{
    error = false;
    connValid = ERR_NOTCONNECTED;
    debugLevel=DBG_NO;
    stream=stderr;
    result=NULL;
    SetConnParams(p);
}


Acaos



ahh yea, that makes sense Cool
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development All times are GMT + 2 Hours
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group