You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When rust drop runs to free waifu, calling free_waifu2x(), a STATUS_ACCESS_VIOLATION or STATUS_STACK_BUFFER_OVERRUN may occur. After taking a look at this ncnn issue it appears to be the reason why.
In the generated code, we can see that ncnn::Net::~Net() is clearly being run after ncnn::destroy_gpu_instance(), thus causing this issue (of which the link before says that should not happen).
After removing ncnn::destroy_gpu_instance(); from ~waifu2x() and placing it at the bottom of free_waifu2x() in order to guarantee the destructor order, I have verified the crash is no longer present (and I have not seen a single crash on exit after this patch). As to why this crash didn't occur in simpler code, I have no clue. But I am using this with a complex program with threading and async, and that seems to have triggered the crashes.
I don't know c++, so I do not know how to edit the code in order to guarantee the destructor order (other than placing ncnn::destroy_gpu_instance() in free_waifu2x()), so I can't offer a PR for this, but I think it should probably be easy to solve?
It might also be worth noting that calling the instance destructor here also appears to have the same problem
i will check this issue tonight 🤔
previously, when I loaded more than 3 models within a process, there would be strange crashes upon program exit
however, the cause was not found before, i suspect that this issue is related to the same problem.
It might also be worth noting that you can also cause a crash in safe code by opening multiple instances
Of course, I figure that the way resources are used, only 1 instance should ever be allowed (since I believe the constructor opens up some resources that can't be opened multiple times, right?), but regardless, the fact remains it's still possible. (Though being able to use multiple instances might be a very nice thing!)
use waifu2x::Waifu2x;fnmain(){let waifu = Waifu2x::new(0,3,2,128,true);let waifu2 = Waifu2x::new(0,3,2,128,true);}
When rust drop runs to free waifu, calling
free_waifu2x()
, aSTATUS_ACCESS_VIOLATION
orSTATUS_STACK_BUFFER_OVERRUN
may occur. After taking a look at this ncnn issue it appears to be the reason why.In the generated code, we can see that
ncnn::Net::~Net()
is clearly being run afterncnn::destroy_gpu_instance()
, thus causing this issue (of which the link before says that should not happen).After removing
ncnn::destroy_gpu_instance();
from~waifu2x()
and placing it at the bottom offree_waifu2x()
in order to guarantee the destructor order, I have verified the crash is no longer present (and I have not seen a single crash on exit after this patch). As to why this crash didn't occur in simpler code, I have no clue. But I am using this with a complex program with threading and async, and that seems to have triggered the crashes.I don't know c++, so I do not know how to edit the code in order to guarantee the destructor order (other than placing
ncnn::destroy_gpu_instance()
infree_waifu2x()
), so I can't offer a PR for this, but I think it should probably be easy to solve?It might also be worth noting that calling the instance destructor here also appears to have the same problem
The text was updated successfully, but these errors were encountered: