Hi. I am having an issue with my files compiled with gcc7 (-std=gnu++17)
this is what ldd displays in my compile machine:
Bitte melden Sie sich an, um diesen Link zu sehen.
(yes, mysqlclient is linked statically)
This is what ldd32 (on freebsd 11.3 64bit) shows of the file db:
Bitte melden Sie sich an, um diesen Link zu sehen.
This is my libmap32.conf:
- # $FreeBSD: releng/11.3/etc/libmap.conf 253853 2013-08-01 05:50:42Z jlh $
- includedir /usr/local/etc/libmap.d
- libgomp.so.1 /usr/local/lib32/compat/libgomp.so.1
- libobjc.so.3 /usr/local/lib32/compat/libobjc.so.4
- libssp.so.0 /usr/local/lib32/compat/libssp.so.0
- libstdc++.so.6 /usr/local/lib/gcc7/libstdc++.so.6
This is what gdb (version 712 in freebsd 9.3 32bit) shows:
Bitte melden Sie sich an, um diesen Link zu sehen.
gcc7 version in FreeBSD 11.3 64bit: 7.5.0
gcc7 version in FreeBSD 9.2 32bit: 7.0.0 20161225 (this machine is from blackdragonx61)
And the code, you can definitely look at what you have, since that part, is completely the same:
- int CClientManager::AnalyzeQueryResult(SQLMsg * msg)
- {
- CQueryInfo * qi = (CQueryInfo *) msg->pvUserData;
- CPeer * peer = GetPeer(qi->dwIdent);
- #ifdef _TEST
- if (qi->iType != QID_ITEM_AWARD_LOAD)
- sys_log(0, "AnalyzeQueryResult %d", qi->iType);
- #endif
- switch (qi->iType)
- {
- case QID_ITEM_AWARD_LOAD:
- ItemAwardManager::instance().Load(msg); //HERE
- delete qi;
- return true;
- }
- void ItemAwardManager::Load(SQLMsg * pMsg)
- {
- MYSQL_RES * pRes = pMsg->Get()->pSQLResult;
- for (uint i = 0; i < pMsg->Get()->uiNumRows; ++i)
- {
- MYSQL_ROW row = mysql_fetch_row(pRes);
- int col = 0;
- DWORD dwID = 0;
- str_to_number(dwID, row[col++]);
- if (m_map_award.find(dwID) != m_map_award.end())
- continue;
- TItemAward * kData = new TItemAward;
- memset(kData, 0, sizeof(TItemAward));
- kData->dwID = dwID;
- trim_and_lower(row[col++], kData->szLogin, sizeof(kData->szLogin));
- str_to_number(kData->dwVnum, row[col++]);
- str_to_number(kData->dwCount, row[col++]);
- str_to_number(kData->dwSocket0, row[col++]);
- str_to_number(kData->dwSocket1, row[col++]);
- str_to_number(kData->dwSocket2, row[col++]);
- str_to_number(kData->bMall, row[col++]);
- if (row[col])
- {
- strlcpy(kData->szWhy, row[col], sizeof(kData->szWhy));
- //게임 중에 why콜룸에 변동이 생기면
- char* whyStr = kData->szWhy; //why 콜룸 읽기
- char cmdStr[100] = ""; //why콜룸에서 읽은 값을 임시 문자열에 복사해둠
- strcpy(cmdStr,whyStr); //명령어 얻는 과정에서 토큰쓰면 원본도 토큰화 되기 때문
- char command[20] = "";
- strcpy(command,CClientManager::instance().GetCommand(cmdStr)); // command 얻기
- //sys_err("%d, %s",pItemAward->dwID,command);
- if( !(strcmp(command,"GIFT") )) // command 가 GIFT이면
- {
- TPacketItemAwardInfromer giftData;
- strcpy(giftData.login, kData->szLogin); //로그인 아이디 복사
- strcpy(giftData.command, command); //명령어 복사
- giftData.vnum = kData->dwVnum; //아이템 vnum도 복사
- CClientManager::instance().ForwardPacket(HEADER_DG_ITEMAWARD_INFORMER,&giftData,sizeof(TPacketItemAwardInfromer));
- }
- }
- m_map_award.insert(std::make_pair(dwID, kData));
- printf("ITEM_AWARD load id %u bMall %d \n", kData->dwID, kData->bMall);
- sys_log(0, "ITEM_AWARD: load id %lu login %s vnum %lu count %u socket %lu", kData->dwID, kData->szLogin, kData->dwVnum, kData->dwCount, kData->dwSocket0);
- std::set<TItemAward *> & kSet = m_map_kSetAwardByLogin[kData->szLogin];
- kSet.insert(kData);
- if (dwID > g_dwLastCachedItemAwardID)
- g_dwLastCachedItemAwardID = dwID;
- }
- }
Does anyone know what can cause this segmentation fault?
Additional info, my Makefile:
- GCC_VERSION = $(shell $(CC) --version 2>&1 | grep "(GCC)" | cut -d' ' -f3 | cut -d'.' -f1)
- CC = gcc7
- CXX = g++7
- INCDIR =
- LIBDIR =
- BINDIR = ../../build/bin
- OBJDIR = ../../build/obj/db
- DEPDIR = ../../build/dep/db
- $(shell if [ ! -d $(BINDIR) ]; then mkdir -p $(BINDIR); fi)
- $(shell if [ ! -d $(OBJDIR) ]; then mkdir -p $(OBJDIR); fi)
- $(shell if [ ! -d $(DEPDIR) ]; then mkdir -p $(DEPDIR); fi)
- # P4
- P4_VERSION = "NO PERFORCE"
- TARGET = $(BINDIR)/db
- #CFLAGS = -g -Wall -O2 -pipe -fno-rtti -fno-exceptions -pthread -D_THREAD_SAFE
- CFLAGS = -gdwarf-2 -O0 -pipe -pthread -std=gnu++17 -D_THREAD_SAFE -fdiagnostics-color=auto
- CFLAGS += -mtune=i686
- # boost
- INCDIR += -I/usr/local/include/boost/
- LIBDIR += -L../../libthecore/lib -L../../libsql -L../../libpoly -L../../libgame/lib
- LIBDIR += -L../../build/lib
- # Project Library
- INCDIR += -I/usr/local/include/
- LIBDIR += -I/usr/local/lib/
- INCDIR += -I/usr/local/include/mysql/
- LIBDIR += -L/usr/local/lib/mysql/
- LIBS = -lthecore -l:libmysqlclient.a -lsql -lpoly -lgame -lm -lz -lstdc++
- SRCS = Config.cpp NetBase.cpp Peer.cpp PeerBase.cpp Main.cpp Lock.cpp DBManager.cpp \
- Cache.cpp LoginData.cpp ClientManager.cpp ClientManagerPlayer.cpp ClientManagerLogin.cpp \
- ClientManagerBoot.cpp ClientManagerParty.cpp ClientManagerGuild.cpp \
- PrivManager.cpp MoneyLog.cpp ItemAwardManager.cpp ClientManagerEventFlag.cpp Marriage.cpp \
- Monarch.cpp BlockCountry.cpp ItemIDRangeManager.cpp ClientManagerHorseName.cpp version.cpp \
- ProtoReader.cpp CsvReader.cpp ClientManagerMyShopEx.cpp GuildManager_rq.cpp \
- ClientKeyManager.cpp Utils.cpp SeasonManager.cpp
- OBJS = $(SRCS:%.cpp=$(OBJDIR)/%.o)
- default: $(TARGET)
- $(TARGET): $(OBJS)
- @echo linking ...
- @$(CC) $(CFLAGS) $(LIBDIR) $(OBJS) $(LIBS) -o $(TARGET)
- @touch version.cpp
- $(OBJDIR)/%.o: %.cpp
- @echo compile $<
- @$(CC) $(CFLAGS) $(INCDIR) -c $< -o $@
- $(OBJDIR)/version.o: version.cpp
- @$(CC) $(CFLAGS) -D__USER__=\"$(USER)\" -D__HOSTNAME__=\"$(HOSTNAME)\" -D__PWD__=\"$(PWD)\" -D__P4_VERSION__=\"$(P4_VERSION)\" -c $< -o $@
- @echo compile $<
- $(OBJDIR):
- @mkdir $(OBJDIR)
- clean:
- @rm -f $(OBJS) $(BINDIR)/db
- dep:
- makedepend -f $(DEPDIR)/Depend $(INCDIR) -I/usr/include/c++/3.3 -I/usr/include/c++/4.2 -p$(OBJDIR)/ $(SRCS) 2> /dev/null > $(DEPDIR)/Depend
- sinclude $(DEPDIR)/Depend