Merge lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash into lp:ubuntu-filemanager-app
| Status: | Needs review | ||||
|---|---|---|---|---|---|
| Proposed branch: | lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash | ||||
| Merge into: | lp:ubuntu-filemanager-app | ||||
| Diff against target: |
196 lines (+47/-4) 7 files modified
src/plugin/folderlistmodel/diriteminfo.cpp (+19/-0) src/plugin/folderlistmodel/diriteminfo.h (+6/-0) src/plugin/folderlistmodel/iorequestworker.cpp (+7/-0) src/plugin/folderlistmodel/location.cpp (+0/-1) src/plugin/folderlistmodel/location.h (+0/-1) src/plugin/folderlistmodel/networklistworker.cpp (+10/-1) src/plugin/folderlistmodel/networklistworker.h (+5/-1) |
||||
| To merge this branch: | bzr merge lp:~renatofilho/ubuntu-filemanager-app/fix-network-crash | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Jenkins Bot | continuous-integration | Needs Fixing on 2017-02-17 | |
| Renato Araujo Oliveira Filho (community) | Disapprove on 2017-01-27 | ||
| Carlos Jose Mazieri | 2017-01-16 | Needs Information on 2017-01-25 | |
|
Review via email:
|
|||
Commit Message
Make sure that NetworkListWorker get invalidated if the parent DirItemInfo was destroyed.
App was crashing because DirItemInfo was destroyed and NetworkListWorker was trying to use an invalid pointer.
- 587. By Renato Araujo Oliveira Filho on 2017-01-18
-
Fix grammar.
| Pat McGowan (pat-mcgowan) wrote : | # |
Renato,
The bug description appears to say that it always crashes.
Can you confirm that it always crashes or it happens under some special condition?
If it happens under special condition can you describe that scenario?
> Renato,
>
> The bug description appears to say that it always crashes.
>
> Can you confirm that it always crashes or it happens under some special
> condition?
>
> If it happens under special condition can you describe that scenario?
It always crash for me.
Does it crash on both phone and desktop or just phone?
OK, Let's have a review on it,
1. perhaps the slot onParentDestroyed() on location.h lines 94-96 is not being used.
2. on line 38 from networklistwork
the default value for 'parent' is 0 on networklistworker.h
38: parent-
3. are you sure the code from networklistwork
the default value for 'parent' is 0 on networklistwork
m_parent is set to 0 and the "m_parent != 0" is checked on line 61.
57: if (!m_parent)
58: return netContent;
61: bool is_parent_
if you want keep lines 57-58, please change to "if (m_parent != 0)" as m_parent is not a boolean type.
4. can you explain why you removed the call to "refreshInfo()" from Location:
on location.cpp line 329?
I see that both Location:
this is the 'parent' used in NetworkListWorker class on the second thread.
That may be the real problem, perhaps just making an attribution into 'm_info'
from the temporary item could solve the entire problem, see a grep output:
./
./
./
./
./
./
Would you consider (adding this) or reconsider for this item #4 only?
| Pat McGowan (pat-mcgowan) wrote : | # |
It always crashes and on both phone and desktop
Thanks for reviewing it.
> OK, Let's have a review on it,
>
> 1. perhaps the slot onParentDestroyed() on location.h lines 94-96 is not being
> used.
REMOVED
>
> 2. on line 38 from networklistwork
> the default value for 'parent' is 0 on networklistworker.h
>
> 38: parent-
FIXED
>
> 3. are you sure the code from networklistwork
> necessary?
> the default value for 'parent' is 0 on networklistwork
> onParentDestroyed() is called
> m_parent is set to 0 and the "m_parent != 0" is checked on line 61.
>
> 57: if (!m_parent)
> 58: return netContent;
>
> 61: bool is_parent_
> m_parent-
>
> if you want keep lines 57-58, please change to "if (m_parent != 0)" as
> m_parent is not a boolean type.
This is not necessary (REMOVED)
>
> 4. can you explain why you removed the call to "refreshInfo()" from
> Location:
> on location.cpp line 329?
>
> I see that both Location:
> the 'm_info',
> this is the 'parent' used in NetworkListWorker class on the second thread.
> That may be the real problem, perhaps just making an attribution into
> 'm_info'
> from the temporary item could solve the entire problem, see a grep output:
>
> ./src/plugin/
> delete m_info;
> ./src/plugin/
> m_info;
> ./src/plugin/
> ./src/plugin/
> ./src/plugin/
> ./src/plugin/
>
> Would you consider (adding this) or reconsider for this item #4 only?
We not not have a pointer to the temporary object (NetworkWorker) from Location class. Or do you have a way to access it?
- 588. By Renato Araujo Oliveira Filho on 2017-01-25
-
Remove unused code.
Check for parent before use it.
Renato,
by temporary objects I mean a temporary DirItemInfo created in Location?? classes, example:
void Location:
{
if (m_info)
{
DirItemInfo *item = newItemInfo(
delete m_info;
m_info = item;
}
}
Would be changed by:
void Location:
{
if (m_info)
{
DirItemInfo *item = newItemInfo(
*m_info = *item; // current m_info item receives current information
delete item;
}
}
I am not sure the operator "=" works properly for all DirItemInfo descendant classes.
Another and easy approach would be if the class NetworkListWorker receive again a const DirItemInfo *parent, but sets m_parent as its own instance using the operator '=', in this case it never gets deleted outside the worker thread.
Suppose the code changed:
NetworkListWork
DirListWork
m_dirIterat
m_mainItemI
m_parent(0)
{
if (parent != 0)
{
m_parent = new UrlItemInfo(); // UrlItemInfo is for remote
*m_parent = *parent; // not sure it works, needs be reviewed
}
mLoaderType = NetworkLoader;
// this would not be necessary and can be removed
parent-
}
NetworkListWork
{
delete m_dirIterator;
delete m_mainItemInfo;
if (m_parent != 0)
{
delete m_parent;
}
}
| Arto Jalkanen (ajalkane) wrote : | # |
I'm a bit dumbfounded that this kind of Qt metaprogramming would be necessary for solving a problem as basic as what we have here. At the minimum I think this code would need to be commented, because if anyone stumbles upon this code in the future it'd be a big WTF moment without clarifying comments. Comments should explain what it fixes, why it had to be done this way.
> Another and easy approach would be if the class NetworkListWorker receive
> again a const DirItemInfo *parent, but sets m_parent as its own instance using
> the operator '=', in this case it never gets deleted outside the worker
> thread.
>
> Suppose the code changed:
>
>
> NetworkListWork
> DirItemInfo * mainItemInfo,
> const DirItemInfo *parent) :
> DirListWorker(
> dirIterator-
> dirIterator-
> : false),
> m_dirIterator(
> m_mainItemInfo(
> m_parent(0)
> {
> if (parent != 0)
> {
> m_parent = new UrlItemInfo(); // UrlItemInfo is for remote
> *m_parent = *parent; // not sure it works, needs be reviewed
> }
> mLoaderType = NetworkLoader;
>
> // this would not be necessary and can be removed
> parent-
> }
>
>
> NetworkListWork
> {
> delete m_dirIterator;
> delete m_mainItemInfo;
> if (m_parent != 0)
> {
> delete m_parent;
> }
> }
With that code the operation will be executed even after the "parent" object be destroyed what we do not want. It is waste of resource.
> I'm a bit dumbfounded that this kind of Qt metaprogramming would be necessary
> for solving a problem as basic as what we have here. At the minimum I think
> this code would need to be commented, because if anyone stumbles upon this
> code in the future it'd be a big WTF moment without clarifying comments.
> Comments should explain what it fixes, why it had to be done this way.
The Qt metaprogramming make things easy here. Avoid big changes. Without that we will need to keep a list of child objects on the parent and invalidate all the children when parent get destroyed.
Instead of that I am keep all the changes on child object and keeping track of parent life. Any suggestion are welcome.
I would remove all the Qt metaprogramming as it is not necessary,
Only a small change in the NetworkListWorker as exposed above should solve the problem, NetworkListWorker class can create its own instance by doing a copy.
Renato,
Can you please test that proposal of that NetworkListWorker creating its own instance of the parent item?
There is a proposal https:/
Also renamed "parent" to "parentItemInfo".
> Renato,
>
> Can you please test that proposal of that NetworkListWorker creating its own
> instance of the parent item?
>
> There is a proposal https:/
> filemanager-
>
> Also renamed "parent" to "parentItemInfo".
Thanks, Carlos will be a pleasure test that.
But as mentioned before if the parent get destroyed the operation will not be canceled and will be executed until the end. (In my opinion this is a wast of resources, but if you are ok with that)
Based on that information I do not think you need to check for (m_parentItemInfo != 0) in line 61. Since m_parentItemInfo will never be null.
Renato,
The check in line 61 is necessary.
The 'parentItemInfo' keeps the information from the parent, which can be: directory/
When the 'mainItemInfo' is root like "smb://" there is no 'parentItemInfo', it can be null.
Another reason it might be used in my regression tests (I am not sure if it is), you can use if you want its in "src/plugin/
Closing this MR
Replaced by: https:/
FAILED: Continuous integration, rev:588
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Unmerged revisions
- 588. By Renato Araujo Oliveira Filho on 2017-01-25
-
Remove unused code.
Check for parent before use it. - 587. By Renato Araujo Oliveira Filho on 2017-01-18
-
Fix grammar.
- 586. By Renato Araujo Oliveira Filho on 2017-01-17
-
Remove extra debug messages.
- 585. By Renato Araujo Oliveira Filho on 2017-01-17
-
Fixed memory leak;
Make sure that works are deleted.
- 584. By Renato Araujo Oliveira Filho on 2017-01-16
-
Avoid crash when aborting a network operation.
Clear parent pointer on worker if parent get destroyed.

Can you explain how this change addresses the issue?