CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15
  1. #1
    John E is online now Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Smile Strange crash with Debug build

    I'm building a program which has a function looking like this (where _mappings is of type std::map) :-

    Code:
    void
    ChanMapping::set(DataType t, uint32_t from, uint32_t to)
    {
    	assert(t != DataType::NIL);
    	Mappings::iterator tm = _mappings.find (t);
    	if (tm == _mappings.end()) {
    		tm = _mappings.insert(std::make_pair(t, TypeMapping())).first; // <--- CRASH HAPPENS HERE !!!!
    	}
    	tm->second.insert(std::make_pair(from, to));
    }
    The Release build runs fine - but whenever I try to debug the program it invariably crashes at the line shown. I decided to place a break point there and trace into the code. But whenever I press F11 to begin the trace, a dialog box pops up :-

    Name:  Capture17.PNG
Views: 704
Size:  39.6 KB

    So I checked my C: drive and sure enough there's no such file. In fact if I navigate to C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC the only subfolder there is 14.28.29333 Can I obtain that older version somehow.? Or alternatively, is there a way I can force MSVC to use the Debug libs that are actually on my system?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Strange crash with Debug build

    Hi John,
    I don't have this file in my 14.28.29333 folder either. Only in 14.20.27508 and 14.16.27023
    But maybe this way will help you:
    https://stackoverflow.com/questions/...d-lib/10234077
    Victor Nijegorodov

  3. #3
    John E is online now Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Strange crash with Debug build

    Thanks VictorN, the advice there seems to be to install something called Spectre Mitigation - though in my case I'm not seeing those link time errors. I just see this strange run time error.

    I must admit, I'm finding VC++ to be pretty troublesome these days...
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Strange crash with Debug build

    14.28.2933 is the latest version for VS2019. 14.16.27023 is the latest version for VS2017. Possibly in the past there's been an issue with a VS update? Have you tried the repair option for VS2019? Also, have you tried deleting all 'intermediate' files (Clean Solution) before a complete solution re-build?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #5
    John E is online now Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Strange crash with Debug build

    Thanks 2kaud - I tend to do a full Clean quite often so it shouldn't be that. However, I might try the Repair option you suggested. BTW - do you know which version corresponds to 14.27.29110.? I assume VS2019 as I don't think I've had anything earlier installed (on this particular machine).
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  6. #6
    John E is online now Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Strange crash with Debug build

    I just found this code in the header file that declares TypeMapping :-

    Code:
        #if defined(_MSC_VER) && (_MSC_VER < 1900)
            /* Use the older (heap based) mapping for early versions of MSVC.
             * In fact it might be safer to use this for all MSVC builds - as
             * our StackAllocator class depends on 'boost::aligned_storage'
             * which is known to be troublesome with Visual C++ :-
             * https://www.boost.org/doc/libs/1_65_0/libs/type_traits/doc/html/boost_typetraits/reference/aligned_storage.html
             */
            typedef std::map<uint32_t, uint32_t>    TypeMapping;
            typedef std::map<DataType, TypeMapping> Mappings;
        #else
            typedef std::map<uint32_t, uint32_t, std::less<uint32_t>, PBD::StackAllocator<std::pair<const uint32_t, uint32_t>, 16> > TypeMapping;
            typedef std::map<DataType, TypeMapping, std::less<DataType>, PBD::StackAllocator<std::pair<const DataType, TypeMapping>, 2> > Mappings;
        #endif
    I removed the _MSC_VER test and that stopped the crash - so it looks like the problems between MSVC and boost::aligned_storage still aren't fixed

    Next step is to figure out why I can't trace into my Debug libraries here (hopefully one of your suggestions here might fix that...)
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  7. #7
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Strange crash with Debug build

    I don't use boost!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  8. #8
    John E is online now Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Strange crash with Debug build

    Quote Originally Posted by 2kaud View Post
    Have you tried the repair option for VS2019?
    2kaud - do you happen to know how I'd launch the Repair option? Under Tools->Nuget Package Manager I've found some options for allowing NuGet to download missing packages - but that's all I found (and those options were both ticked anyway...)
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Strange crash with Debug build

    To launch the Repair option for VS2019 you should start the VS Installer, then click the dropbox More and select Repair in context menu.
    Attachment 35948
    Victor Nijegorodov

  10. #10
    John E is online now Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Strange crash with Debug build

    Boy! That Repair option sure makes some changes!! It kept some of my preferences (and history lists etc) but it pretty much put me back to the state of having a fresh install. Sadly, one thing it didn't do was to fix that dialog (from my original post).

    I then hit on a bright idea... I copied the currently installed folder (14.28 29333) and pasted it back - renamed as 14.27.29110. I hoped this might fool VS2019 into thinking that the older option was installed now - but it doesn't seem to work. What happens now (whenever I try to trace into one of the MSVC functions) is that it pops up a new dialog window which doesn't help much:-

    Name:  Capture18.PNG
Views: 622
Size:  53.9 KB

    I guess I'll need to get the correct library for 14.27.29110 somehow and see if that works.
    Last edited by John E; February 18th, 2021 at 05:58 AM.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  11. #11
    John E is online now Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Strange crash with Debug build

    I just came across this web page. About half way down there's a suggestion for how to check (and change) the toolset that Visual Studio will use. I've just checked mine here and they're all set (apparently correctly) to 14.28.29333. There's no mention in any of them about 14.27.29110.

    So it looks like my only option here is to obtain a copy of the 14.27.29110 toolset somehow. Does anyone know if they're downloadable from anywhere?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  12. #12
    John E is online now Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Strange crash with Debug build

    Groan - having accepted that I'll just have to tolerate these problems in my Debug build, I've hit an even bigger problem now with the Release build

    The various DLL's all seem to build fine and the main exe compiles okay - but when it gets to the link stage, the linker bails out with these error messages:-

    1>LINK : the 32-bit linker (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\link.exe) ran out of heap space and is going to restart linking with a 64-bit linker
    1>LINK : restarting link with 64-bit linker `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX64\x64\link.exe'
    1>LINK : fatal error LNK1104: cannot open file 'F:\+GTK-SOURCES\Mixbus32C\MSVCardour3\x64\Release\bin\Mixbus64.exe'
    I've tried changing the output folder for the linked file (e.g. in case there was some access issue) but nothing seems to work. The linker generates a small stub file (approximate size 2MB) and then bails out. Has anyone ever seen something like this? I've 64GB of RAM installed so there shouldn't be a problem with heap space
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  13. #13
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Strange crash with Debug build

    I never saw this error message.
    However the others did:
    https://www.google.com/search?q=ran+...hrome&ie=UTF-8
    Victor Nijegorodov

  14. #14
    John E is online now Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: Strange crash with Debug build

    Many thanks Victor.... under Configuration Properties->Advanced I need to select 64-bit (x64) as my preferred build tool architecture (I'm guessing that makes it use the 64-bit architecture directly - rather than going via the 32-bit one). Anyway, it's linking fine now!!

    [Edit...] Unfortunately the site won't let me give you another rating - but much appreciated !
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  15. #15
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Strange crash with Debug build

    Quote Originally Posted by John E View Post
    Many thanks Victor....
    You are welcome!

    Quote Originally Posted by John E View Post
    Unfortunately the site won't let me give you another rating - but much appreciated !
    Don't worry! I have more than enough rating points!
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured