[Interest] Unknown crashes with Qt, iOS and iPad Air

Nuno Santos nunosantos at imaginando.pt
Tue Apr 21 18:10:36 CEST 2015


Hi there,

I have finally found the problem to this weird crashes. They were only happening in 64bit devices like iPad Air because their are probably faster. The problem as very subtil and did not occurred on iPad 2. See the commented line below:

- (void)netServiceDidResolveAddress:(NSNetService *)sender
{
    for (NSData *address in [sender addresses])
    {
        struct sockaddr_in *socketAddress = (struct sockaddr_in *) [address bytes];

        if (socketAddress && socketAddress->sin_family==AF_INET)
        {
            LKBridgeBrowser::instance()->bridgeAdded(QString::fromNSString(sender.name), QString::fromLocal8Bit(inet_ntoa(socketAddress->sin_addr)), [sender port]);
            
            [services removeObject:sender]; // this line was before the previous. On slower devices, this was not a problem. I believe the garbage collection only happened after. Sinc the object was already deleted, it was causing a segmentation fault. 
        }
    }
}

I just wanted to share with you.

Thanks,

Regards,

Nuno

> On 20 Apr 2015, at 14:54, Nuno Santos <nunosantos at imaginando.pt> wrote:
> 
> Alejandro,
> 
> Thanks for your reply.
> 
>> On 20 Apr 2015, at 13:07, Alejandro Exojo <suy at badopi.org> wrote:
>> 
>> El Monday 20 April 2015, Nuno Santos escribió:
>>> I’m currently using a QTcpSocket moved to a thread. I’m not sure i’m doing
>>> it the right way. I was trying to optimize the thought put of the socket
>>> in order to avoid latency.
>> 
>> Creating threads for I/O is almost always wrong. The interface that sockets in 
>> Qt have is asynchronous. Unless you do something slow with the data tha slows 
>> down everything else, you don't need threads for that.
> 
> I’m working on a new version of the app where I’m already dropping the usage of threads.
> 
>> 
>>> void LKSong::connectTo(QString name, QString address, int port)
>>> {
>>>   terminateConnection();
>>> 
>>>   _thread = new QThread(this);
>>>   _connection = new LKConnection(QHostAddress(address),port);
>> 
>> A new thread per connection seems even more problematic. :)
>> 
>> Anyway, how/when are you deleting this thread and this LKConnection objects?
>> 
>> In that screenshot you have 18 threads. Is this normal? 
> 
> Right now, I don’t have threads created by me and it counts 14 threads, so I guess it is normal and the underlying parts of Qt and iOS are creating them.
> 
> Regards,
> 
> Nuno
> 
>> 
>> -- 
>> Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2
>> http://barnacity.net/ | http://disperso.net
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150421/20a493a8/attachment.html>


More information about the Interest mailing list