sepoto
1st April 2011, 10:09 PM
I know that a segmentation fault normally occurs when I try to access a vector's address that does not exist or is outside of it's bounds. I looked at my code and I do not see anywhere where this might be occuring. This segmentation fault does not occur every time I run my program. It only occurs infrequently which is making it all that much harder to de bug it. I would post my code to the mysqlpp mailing list but they always flame me and tell me to go read a book on C++. Maybe someone out there has a more trained eye than I do and can spot quickly what the problem is. If not I will keep working on it. Thank all of you for your time and patience.
vector< vector<string> > dig(string ssport) {
Query qbasketballlineup = conn.query();
qbasketballlineup << "SELECT tf_database_key, tf_reduced_titlec, tf_reduced_descc, tf_genre_desc138, tf_epi_title, tf_game_date FROM sports_program where tf_genre_desc138 like '%"<< ssport << "%' and tf_genre_desc137='Sports event' and tf_game_date between '" + yestdate + "' and '" + tomdate + "' order by tf_reduced_titlec;";
vector<mysqlpp::Row> vbasketballlineup;
qbasketballlineup.storein(vbasketballlineup);
vector< vector<string> > basketball;
for(int a=0;a<(int)vbasketballlineup.size();a++) {
vector<string> mychans;
vector<int> vair_time;
Query qbasketballevent = conn.query();
qbasketballevent << "select distinct tf_live_tape_delay,tf_air_date,tf_air_time,tf_stat ion_num,tf_database_key,tf_hdtv from sports_schedule where tf_database_key='" <<string(vbasketballlineup[a]["tf_database_key"])<<"' and tf_live_tape_delay='Live' and tf_hdtv='N'";
vector<mysqlpp::Row> vbasketballevent;
qbasketballevent.storein(vbasketballevent);
for(int b=0;b<(int)vbasketballevent.size();b++) {
int air_time = atoi(vbasketballevent[b]["tf_air_time"]);
string air_date = string(vbasketballevent[b]["tf_air_date"]);
air_time = cnvrtime(air_time,string(mytz[0]["TZ"]),tm_isdst);
if(air_time<0) { air_time = 2400 + air_time; air_date = sub1day(air_date); }
cout << air_date << "," << air_time << "," << ssport << endl;
if(air_date == todaysdate) {
vair_time.push_back(air_time);
Query queryh = conn.query();
queryh<<"select * from sat_lineup_record where cl_headend_id='"<<string(vmysathead[0])<<"' and cl_station_num='"<<string(vbasketballevent[b]["tf_station_num"])<<"'";
StoreQueryResult satchan = queryh.store();
if(satchan.num_rows()>0) {
for(int c=0;c<(int)satchan.num_rows();c++) {
string temp = string(satchan[c]["cl_tms_chan"]);
temp = temp;
mychans.push_back(string(temp));
cout << temp << endl;
}
}//if satchan
}//todaysdate
}//b for ss
Query qbasketballevent2 = conn.query();
qbasketballevent2 << "select distinct tf_live_tape_delay,tf_air_date,tf_air_time,tf_stat ion_num,tf_database_key,tf_hdtv from sports_schedule where tf_database_key='" <<string(vbasketballlineup[a]["tf_database_key"])<<"' and tf_live_tape_delay='Live' and tf_hdtv='Y'";
vector<mysqlpp::Row> vbasketballevent2;
qbasketballevent2.storein(vbasketballevent2);
for(int b=0;b<(int)vbasketballevent2.size();b++) {
int air_time = atoi(vbasketballevent2[b]["tf_air_time"]);
string air_date = string(vbasketballevent2[b]["tf_air_date"]);
air_time = cnvrtime(air_time,string(mytz[0]["TZ"]),tm_isdst);
if(air_time<0) { air_time = 2400 + air_time; air_date = sub1day(air_date); }
cout << air_date << "," << air_time << "," << ssport << endl;
if(air_date == todaysdate) {
vair_time.push_back(air_time);
Query queryh = conn.query();
queryh<<"select * from sat_lineup_record where cl_headend_id='"<<string(vmysathead[0])<<"' and cl_station_num='"<<string(vbasketballevent[b]["tf_station_num"])<<"'";
StoreQueryResult satchan = queryh.store();
if(satchan.num_rows()>0) {
for(int c=0;c<(int)satchan.num_rows();c++) {
string temp = string(satchan[c]["cl_tms_chan"]);
temp = temp + "HD";
mychans.push_back(string(temp));
cout << temp << endl;
}
}//if satchan
}//todaysdate
}//b for ss
sort(mychans.begin(),mychans.end(),myLessThan());
sort(vair_time.begin(),vair_time.end());
for(int b=0;b<(int)mychans.size();b++) { cout << mychans[b] << endl; }
for(int c=0;c<(int)mychans.size();c++) {
for(int d=c+1;d<(int)mychans.size();d++) {
if(mychans[c]==mychans[d]) { mychans.erase(mychans.begin()+d); }
}
}
if(mychans.size()>0) {
//cout << vair_time[0] << "," << vbasketballlineup[a]["tf_reduced_titlec"] << "," << vbasketballlineup[a]["tf_epi_title"];
vector<string> temp;
stringstream sstemp;
sstemp << vair_time[0];
temp.push_back(sstemp.str());
temp.push_back(string(vbasketballlineup[a]["tf_reduced_titlec"]));
temp.push_back(string(vbasketballlineup[a]["tf_epi_title"]));
string stemp;
for(int b=0;b<(int)mychans.size();b++) {
stemp = stemp + string(mychans[b]) + ", ";
}
temp.push_back(stemp);
basketball.push_back(temp);
}
}
return basketball;
}
vector< vector<string> > dig(string ssport) {
Query qbasketballlineup = conn.query();
qbasketballlineup << "SELECT tf_database_key, tf_reduced_titlec, tf_reduced_descc, tf_genre_desc138, tf_epi_title, tf_game_date FROM sports_program where tf_genre_desc138 like '%"<< ssport << "%' and tf_genre_desc137='Sports event' and tf_game_date between '" + yestdate + "' and '" + tomdate + "' order by tf_reduced_titlec;";
vector<mysqlpp::Row> vbasketballlineup;
qbasketballlineup.storein(vbasketballlineup);
vector< vector<string> > basketball;
for(int a=0;a<(int)vbasketballlineup.size();a++) {
vector<string> mychans;
vector<int> vair_time;
Query qbasketballevent = conn.query();
qbasketballevent << "select distinct tf_live_tape_delay,tf_air_date,tf_air_time,tf_stat ion_num,tf_database_key,tf_hdtv from sports_schedule where tf_database_key='" <<string(vbasketballlineup[a]["tf_database_key"])<<"' and tf_live_tape_delay='Live' and tf_hdtv='N'";
vector<mysqlpp::Row> vbasketballevent;
qbasketballevent.storein(vbasketballevent);
for(int b=0;b<(int)vbasketballevent.size();b++) {
int air_time = atoi(vbasketballevent[b]["tf_air_time"]);
string air_date = string(vbasketballevent[b]["tf_air_date"]);
air_time = cnvrtime(air_time,string(mytz[0]["TZ"]),tm_isdst);
if(air_time<0) { air_time = 2400 + air_time; air_date = sub1day(air_date); }
cout << air_date << "," << air_time << "," << ssport << endl;
if(air_date == todaysdate) {
vair_time.push_back(air_time);
Query queryh = conn.query();
queryh<<"select * from sat_lineup_record where cl_headend_id='"<<string(vmysathead[0])<<"' and cl_station_num='"<<string(vbasketballevent[b]["tf_station_num"])<<"'";
StoreQueryResult satchan = queryh.store();
if(satchan.num_rows()>0) {
for(int c=0;c<(int)satchan.num_rows();c++) {
string temp = string(satchan[c]["cl_tms_chan"]);
temp = temp;
mychans.push_back(string(temp));
cout << temp << endl;
}
}//if satchan
}//todaysdate
}//b for ss
Query qbasketballevent2 = conn.query();
qbasketballevent2 << "select distinct tf_live_tape_delay,tf_air_date,tf_air_time,tf_stat ion_num,tf_database_key,tf_hdtv from sports_schedule where tf_database_key='" <<string(vbasketballlineup[a]["tf_database_key"])<<"' and tf_live_tape_delay='Live' and tf_hdtv='Y'";
vector<mysqlpp::Row> vbasketballevent2;
qbasketballevent2.storein(vbasketballevent2);
for(int b=0;b<(int)vbasketballevent2.size();b++) {
int air_time = atoi(vbasketballevent2[b]["tf_air_time"]);
string air_date = string(vbasketballevent2[b]["tf_air_date"]);
air_time = cnvrtime(air_time,string(mytz[0]["TZ"]),tm_isdst);
if(air_time<0) { air_time = 2400 + air_time; air_date = sub1day(air_date); }
cout << air_date << "," << air_time << "," << ssport << endl;
if(air_date == todaysdate) {
vair_time.push_back(air_time);
Query queryh = conn.query();
queryh<<"select * from sat_lineup_record where cl_headend_id='"<<string(vmysathead[0])<<"' and cl_station_num='"<<string(vbasketballevent[b]["tf_station_num"])<<"'";
StoreQueryResult satchan = queryh.store();
if(satchan.num_rows()>0) {
for(int c=0;c<(int)satchan.num_rows();c++) {
string temp = string(satchan[c]["cl_tms_chan"]);
temp = temp + "HD";
mychans.push_back(string(temp));
cout << temp << endl;
}
}//if satchan
}//todaysdate
}//b for ss
sort(mychans.begin(),mychans.end(),myLessThan());
sort(vair_time.begin(),vair_time.end());
for(int b=0;b<(int)mychans.size();b++) { cout << mychans[b] << endl; }
for(int c=0;c<(int)mychans.size();c++) {
for(int d=c+1;d<(int)mychans.size();d++) {
if(mychans[c]==mychans[d]) { mychans.erase(mychans.begin()+d); }
}
}
if(mychans.size()>0) {
//cout << vair_time[0] << "," << vbasketballlineup[a]["tf_reduced_titlec"] << "," << vbasketballlineup[a]["tf_epi_title"];
vector<string> temp;
stringstream sstemp;
sstemp << vair_time[0];
temp.push_back(sstemp.str());
temp.push_back(string(vbasketballlineup[a]["tf_reduced_titlec"]));
temp.push_back(string(vbasketballlineup[a]["tf_epi_title"]));
string stemp;
for(int b=0;b<(int)mychans.size();b++) {
stemp = stemp + string(mychans[b]) + ", ";
}
temp.push_back(stemp);
basketball.push_back(temp);
}
}
return basketball;
}