Skip to content
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

hpx::init calls wrong (first) callback when called multiple times #2918

Closed
msimberg opened this issue Sep 29, 2017 · 3 comments · Fixed by #2919
Closed

hpx::init calls wrong (first) callback when called multiple times #2918

msimberg opened this issue Sep 29, 2017 · 3 comments · Fixed by #2919

Comments

@msimberg
Copy link
Contributor

The following code does not work as expected:

#include <hpx/hpx_init.hpp>
#include <iostream>

int hpx_init_test(std::string s, int argc, char ** argv)
{
    std::cout << "string is " << s << std::endl;
    return hpx::finalize();
}

int main (int argc, char *argv[])
{
    using hpx::util::placeholders::_1;
    using hpx::util::placeholders::_2;

    hpx::util::function_nonser<int(int, char**)> callback1 = hpx::util::bind(&hpx_init_test, "first", _1, _2);
    hpx::init(callback1, "name", argc, argv, hpx::runtime_mode_default);

    hpx::util::function_nonser<int(int, char**)> callback2 = hpx::util::bind(&hpx_init_test, "second", _1, _2);
    hpx::init(callback2, "name", argc, argv, hpx::runtime_mode_default);

    hpx::util::function_nonser<int(int, char**)> callback3 = hpx::util::bind(&hpx_init_test, "third", _1, _2);
    hpx::init(callback3, "name", argc, argv, hpx::runtime_mode_default);

    return 0;
}

Expected output:

first
second
third

Actual output:

first
first
first

This is on latest master (f032046).

@hkaiser
Copy link
Member

hkaiser commented Sep 29, 2017

The second and third call to hpx::init should actually throw an exception. This is what needs to be fixed, not the callback invoked..

@biddisco
Copy link
Contributor

Why is that - we used to be able to call init multiple times - is it because the 2nd and 3rd calls should not pass argc,argv since the command line has been parsed already?

@hkaiser
Copy link
Member

hkaiser commented Sep 29, 2017

@biddisco Yes, you're right - please disregard my comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants