We help IT Professionals succeed at work.

boost::uuid crashes

Knut Hunstad
Knut Hunstad asked
on
487 Views
Last Modified: 2018-05-16
Hi!

I am trying to compare speed of boost::uuid vs UUidCreate from rpc.h. But the boost version crashes quite quickly in this loop! Any ideas?

# include <boost/uuid/uuid.hpp>
# include <boost/uuid/uuid_io.hpp>
# include <boost/uuid/random_generator.hpp>

  static boost::uuids::random_generator gen;
  for (int i = 0; i < 10000000; ++i)
    to_string(gen());

Open in new window


Is there really any reason we should prefer the boost version?

Thank you!
Comment
Watch Question

evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
Platform? Compiler? Boost version?
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
FWIW, I tried this is Visual Studio 2017 on a Windows 10 machine with boost_1_62_0 and had no problems.
CERTIFIED EXPERT
Top Expert 2016

Commented:
do you run this in debug mode or release? and is the project with clr and/or native c++?

if 10,000,000 objects were created with gc you might get memory issues depending on your environment.

you probably got some messages in the debug output window when the crash happens?

Sara

Author

Commented:
Boost 1.59
VS 2015, compiled with platform toolset v140, no clr, release version (so no debug output)
The exception message says there is a "System.AccessViolationException".
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
Have you considered trying the latest version of Boost? That version is pretty old. You can download precompiled binaries from the Boost website.

Author

Commented:
Ok, I downloaded boost 1_63_0 (got lot's of errors packing out the zip file, but the necessary files for uuid seem ok).

No difference, still crashes...

Author

Commented:
I have tried with:

#define BOOST_UUID_NO_SIMD

before inclusion of the boost headers, no difference...
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
You built Boost yourself or used the precompiled binaries? I always use the precompiled binaries, which can be installed using the provided setup file.
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:

Author

Commented:
Isn't uuid headers only?
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
Good point. It could be. To be completely honest I didn't check. Very weird you're seeing this crash though. I've used this in production a number of times without issue. Without being able to reproduce the issue, it's hard to know what else to check other than to recommend trying it on a completely different machine just to rule out environmental factors. Maybe also try checking you have the latest 2015 updates or even try VS2017.

Author

Commented:
I can't really switch compiler, this is a huge system with many components. We have never seen any problems (as far as we know) with this in normal use. But I got sceptical when I made this test and got a crash.

Anyway, the main question is actually why should we use boost for this at all and not the rpc version instead?

Thanks for trying to help!
Senior Software Engineer (Avast)
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
I am going for dropping the boost version, since we don't use boost anywhere else. So even though the crash problem wasn't solved, I got help to reach my conclusion on what to do because of the comment about boost not really making any difference.

Thank you!
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
You're welcome. If you do ever figure out why it crashes, I'd be curious to know the reason.

All the best.
CERTIFIED EXPERT
Top Expert 2016

Commented:
does it crash in debug mode as well? or if you decrease the loop count? access violation always means pointer error. as the destructor definitively would free all pointers before next loop cycle and next construction would/could use the same heap memory again,  in my opinion the crash only could happen because of optimization the compiler has made for the loop. you could turn off optimization or print the generated guid to a file. both should at least change the behavior, perhaps even solve the issue.

why should we use boost for this at all and not the rpc version instead?
i think you have answered the question to yourself, that you won't go to boost as long as the issue is not resolved. i would not see any reason to prefer boost even if it was faster.

Sara

Author

Commented:
Thank you Sara! I had already tested streaming the guids to a file before I even asked this question. Things crashed right in the middle of it, and the file would have less guids than expected and the last one could even be shorter than supposed.

I won't be spending any more time on this, since I kicked out boost.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.