RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
997 stars 182 forks source link

Hang in ospInit() #388

Closed paulmelis closed 4 years ago

paulmelis commented 4 years ago

With the recent changes to the command-line handling and parsing I now have ospInit() getting stuck. I can't immediately figure out why it doesn't get out of ospInit(), but I'm calling it in a slightly non-standard way. Instead of passing argc and argv from main() I'm using a vector of strings containing arguments that get converted to a temporary array of values like this (this is a reduced test case, btw):

#include <ospray/ospray_cpp.h>

using namespace ospray::cpp;

std::vector<std::string>
init(const std::vector<std::string>& args)
{
    int argc = args.size();
    const char **argv = new const char*[argc];

    for (int i = 0; i < argc; i++)
        argv[i] = args[i].c_str();

    OSPError res = ospInit(&argc, argv);

    if (res != OSP_NO_ERROR)
    {
        delete [] argv;
        std::string msg = "ospInit() failed: " + std::to_string(res);
        throw std::runtime_error(msg);
    }

    std::vector<std::string> newargs;

    for (int i = 0; i < argc; i++)
        newargs.push_back(std::string(argv[i]));

    delete [] argv;

    return newargs;
}

int main(int argc, const char *argv[])
{
    std::vector<std::string> args;

    args.push_back("python");
    args.push_back("./plyrender.py");
    args.push_back("--osp:debug");
    args.push_back("tests/pyramid.ply");

    init(args);
}

This is with 098fd12e7ef1fcbfc4c73c391161df69e63ace7e.

paulmelis commented 4 years ago

Easier reproduction: ospTutorial doh --osp:debug.

paulmelis commented 4 years ago

For unrecognized arguments i is never increased:

https://github.com/ospray/ospray/blob/098fd12e7ef1fcbfc4c73c391161df69e63ace7e/ospray/common/OSPCommon.cpp#L73-L85

https://github.com/ospray/ospray/blob/098fd12e7ef1fcbfc4c73c391161df69e63ace7e/ospray/common/OSPCommon.cpp#L156-L168

paulmelis commented 4 years ago

Pull request #389

paulmelis commented 4 years ago

Pull request was merged, issue fixed