Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
HuXu77
Posts: 195
Registered: ‎02-10-2011
My Device: Playbook 16GB and Z10
My Carrier: Verizon
Accepted Solution

Segfault Strange Behavior

[ Edited ]

This has me for a loop, here is the code:

 

void GoogleMusicApi::loadSong(const QVariantMap song) {
	songIdToSave = song.value("id").toString();
	QString url;
	connector = NULL;
	connector = new UrlConnector;
	connect(connector, SIGNAL(complete(QString)), this, SLOT(onSongUrl(QString)), Qt::UniqueConnection);
	connect(this, SIGNAL(abortConnection()), connector, SLOT(cancelRequest()), Qt::UniqueConnection);
	connect(connector, SIGNAL(networkError(QString,QString)), this, SLOT(onError(QString,QString)));
	if (song.value("type").toInt() == 7) {
		// All Access Type
		AllAccessHelper * helper = new AllAccessHelper;
		QString salt = helper->getSalt();
		QString saltAndSong(songIdToSave + salt);
		unsigned char* message;
		helper->getSig(saltAndSong, message);
		QByteArray mess = QByteArray::fromRawData(reinterpret_cast<char*>(message), SB_HMAC_SHA1_160_TAG_LEN);
		QString hash = QString::fromUtf8(mess.toBase64());
		hash = hash.replace("+", "-");
		hash = hash.replace("/", "_");
		QString sig = hash.replace("=", ".");
		qDebug() << "GMA: Salt: " << salt;
		qDebug() << "GMA: SaltSong: " << saltAndSong;
		qDebug() << "GMA: Sig: " << sig;
		qDebug() << "GMA: Before base64: " << QString::fromUtf8(mess.toHex());
		url = QString(MUSIC_PLAY_AASONGID.arg(salt).arg(songIdToSave).arg(sig));
		helper->deleteLater();
	} else {
		url = MUSIC_PLAY_SONGID.arg(songIdToSave);
	}
	connector->get(url);
}

 To walk you through the issue, I call this method, then based on All Access type I do some different things to build the URL string.  Doesn't seem to strange or weird as the URL string ends up being exactly what I am looking for but whats strange is my connector (UrlConnector).  If I move 

 

connector = NULL;
connector = new UrlConnector;
connect(connector, SIGNAL(complete(QString)), this, SLOT(onSongUrl(QString)), Qt::UniqueConnection);
connect(this, SIGNAL(abortConnection()), connector, SLOT(cancelRequest()), Qt::UniqueConnection);
connect(connector, SIGNAL(networkError(QString,QString)), this, SLOT(onError(QString,QString)));

 after my if statement and the song type is All Access, so I do all that hashing stuff, then the moment I hit this first connect() I get a segfault on connect, which the only other time I get a segfault on a connect is if one of the values is null, but when I breakpoint here, connector is not null.  Also this only happens when I do the hashing stuff, if the song is not All Access and I just have to build a string with the songId, then I don't segfault on the connect.

 

Any ideas as to how the hashing has anything to do with this connect?!

_________________________________________________
Apps
Go Music
Flashlight Fast Free/Pro
Fitbit for BlackBerry PlayBook
Please use plain text.
Developer
HuXu77
Posts: 195
Registered: ‎02-10-2011
My Device: Playbook 16GB and Z10
My Carrier: Verizon

Re: Segfault Strange Behavior

Ok I figured out the issue, not sure which was the fix, but my first issue was

 

unsigned char *message;

changed to 

unsigned char message[SB_HMAC_SHA1_160_TAG_LEN];

 And I also added

 

AllAccessHelper::AllAccessHelper() {}

changed to 

AllAccessHelper::AllAccessHelper() :
QObject() {}

 

_________________________________________________
Apps
Go Music
Flashlight Fast Free/Pro
Fitbit for BlackBerry PlayBook
Please use plain text.