GitHub issue: free(): invalid pointer after trying to load torch model
State: closed

Hello, 
After I was trying to load a torch model, and it failed, I get every time I execute run-validate_11.sh an invalid pointer error. The error persists even when I set the code as it originally was and build it again. For info, I'm building the null implementation. 

You can find below the message of the error:
 -------------------------
Running 1:1 validation
-------------------------

Checking for hard-coded config directory free(): invalid pointer
PID 142393 exited due to signal 6
free(): invalid pointer
scripts/run_testdriver.sh line 68: 142392 Aborted

There's a test in the validation script that ensures you fail when the config directory is missing.

It appears that you are failing to load your torch model, as you should, which will return an invalid pointer.

However, you have failed to verify that 1) the model file existed, 2) permissions are correct and most importantly. 3) the model loaded. So when it comes time to clean up, you have attempted to free an invalid pointer.

No, the config folder exists.
As mentioned in my original message, after I change my code and try no more to load the torch model (I set the null implementation as it originally was), the validation script keeps throwing the same error. With the same original code, it was compiling before.
I think there is a problem with the logs the validation script uses.

"Checking for hard-coded config directory"
When this is printed, the script has renamed config to otherConfig. If the config folder still exists here then something is changed or broken in the configuration or source.

 free(): invalid pointer
When this is printed, your code has called free to a bogus pointer, observable in GDB. If you still can't see why this happens, look at the backtrace from GDB.

Is not my code that has called free to a pointer.
I set the code back to a version that used to pass all the tests.

You may go back to an older version where this test wasn't performed but I believe it won't be accepted.
Can you provide the backtrace?

This is what I get when I build the original null Implementation:

Checking for hard-coded config directory free(): invalid pointer
PID 29153 exited due to signal 6
free(): invalid pointer
scripts/run_testdriver.sh: line 68: 29512 Aborted

You'll need to run it with gdb, such as:
gdb --args myapp
You can add it to the script.
Then type 'b' and enter once it crashes.
This should show you which line it crashed on.

If you clean the config / otherConfig, I assume your crash at that point goes away. So you should do this in your code instead of the null implementation.

Ok, I had to disable the fork() part of the main() of validate11.cpp in order to debug it entirely.
The error is coming from line 86:
auto ret = implPtr->createTemplate(faces, role, templ, eyes);

The error persists even when I do nothing on the 'createTemplate' function and just return the Success status.

Hello,
The problem is solved when I include the same libraries (Torch and Opencv) at the validate11 side, that I used for my implementation. I wonder, will that be a problem when NIST will evaluate my library?

You mean you had used different versions of the libraries when running validate11? The correct libraries should be included in your implementation's lib/ path. It all gets zipped (lib, config, doc) for your submission.

I linked those libraries statically and the problem is solved. Thank you.