-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STATUS_ACCESS_VIOLATION
or STATUS_STACK_BUFFER_OVERRUN
when free_waifu2x()
called
#4
Comments
i will check this issue tonight 🤔 |
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;
fn main() {
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: