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

infinite loop in managed_open_or_create_impl.hpp if filesize is 0 #130

Closed
cmorty opened this issue Sep 17, 2020 · 2 comments
Closed

infinite loop in managed_open_or_create_impl.hpp if filesize is 0 #130

cmorty opened this issue Sep 17, 2020 · 2 comments

Comments

@cmorty
Copy link

cmorty commented Sep 17, 2020

Calling managed_mapped_file(bip::open_only,filename) on a file with size 0 results in a in infinite loop.

            offset_t filesize = 0;
            spin_wait swait;
            while(filesize == 0){
               if(!get_file_size(file_handle_from_mapping_handle(dev.get_mapping_handle()), filesize)){
                  error_info err = system_error_code();
                  throw interprocess_exception(err);
               }
               swait.yield();
            }
@igaztanaga
Copy link
Member

A correctly created managed file can't have zero size. Code is waiting the create process to initialize the managed file (in case of error, file will be truncated to size 1). Which is your use case?

@igaztanaga
Copy link
Member

Thanks for the report. The implementation will add deadlock detection code with configurable macros BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_INITIALIZE_MAX_TRIES/BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_INITIALIZE_TIMEOUT_SEC to handle those situations, as there is no reliable way to detect the other process creating the resource is dead or not.

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

No branches or pull requests

2 participants