Menu

#305 Assert failure: invalid encoding value in wxCSConv ctor

Next_Nightly
open
wx30 (74)
Bug_Report
2017-11-06
2016-02-22
Riot
No

When doing a search and replace across multiple files, this error pops up repeatedly:

ASSERT INFO:
../src/common/strconv.cpp(3031): assert "Assert failure" failed in wxCSConv(): invalid encoding value in wxCSConv ctor

BACKTRACE:
[1] wxCSConv::wxCSConv(wxFontEncoding)
[2] DetectEncodingAndConvert(char const*, wxString&, wxFontEncoding)
[3] cbRead(wxFile&, wxString&, wxFontEncoding)
[4] cbReadFileContents(wxFile&, wxFontEncoding)
[5] wxTextEntryBase::Clear()
[6] wxTextEntryBase::Clear()
[7] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const
[8] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)
[9] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
[10] wxEvtHandler::TryHereOnly(wxEvent&)
[11] wxEvtHandler::DoTryChain(wxEvent&)
[12] wxEvtHandler::ProcessEvent(wxEvent&)
[13] wxWindowBase::TryAfter(wxEvent&)
[14] wxWindowBase::TryAfter(wxEvent&)
[15] wxWindowBase::TryAfter(wxEvent&)
[16] wxMenuCmd::Exec(wxObject*, wxEvtHandler*)
[17] wxKeyBinder::OnChar(wxKeyEvent&, wxEvtHandler*)
[18] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const
[19] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)
[20] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
[21] wxEvtHandler::TryHereOnly(wxEvent&)
[22] wxEvtHandler::ProcessEventLocally(wxEvent&)
[23] wxEvtHandler::ProcessEvent(wxEvent&)
[24] wxEvtHandler::SafelyProcessEvent(wxEvent&)
[25] g_closure_invoke
[26] g_signal_emit_valist
[27] g_signal_emit
[28] gtk_window_propagate_key_event
[29] g_closure_invoke
[30] g_signal_emit_valist
[31] g_signal_emit
[32] gtk_propagate_event
[33] gtk_main_do_event
[34] g_main_context_dispatch
[35] g_main_loop_run
[36] gtk_main
[37] wxGUIEventLoop::DoRun()
[38] wxEventLoopBase::Run()
[39] wxAppConsoleBase::MainLoop()
[40] main
[41] wxEntry(int&, wchar_t**)
[42] main
[43] __libc_start_main
[44] main

Version 16.01 on linux, 64bit.

Discussion

  • Teodor Petrov

    Teodor Petrov - 2016-02-22
    • labels: --> wx30
    • Type: Undefined --> Bug_Report
    • Milestone: Undefined --> Next_Nightly
     
  • Teodor Petrov

    Teodor Petrov - 2016-02-22

    We'll need a bit more info.
    1. what is the system encoding you're using?
    2. does it happen with every project and every file in it?

     
    • Riot

      Riot - 2016-02-25

      System encoding is utf-8. It does not happen reliably - perhaps there is some race condition. It happens several times when searching and replacing in large projects - all files should be utf-8 in all cases, as far as I'm aware.

       
  • Teodor Petrov

    Teodor Petrov - 2016-02-25

    Doesn't help much. Build a debugger version, use a debugger and inspect the backtrace if you can see which file is causing this problem. Then inspect the file or share it.
    Does it happen if you repeat the operation with the same files and keywords.

    I doubt it is a race condition, because as far as I know the search/replace is done in the main thread. My guess is that some file is broken/strange encoding and the bug trigger only when you replace something in it. And unfortunately this doesn't happen very often.

     
    • Riot

      Riot - 2016-02-26

      If you provide a debug build I would be happy to run it in gdb, if you tell me what breakpoints I ought to set to check for this. If you really want to fix bugs rather than just brushing them off and pretending they don't exist, you need to support bug reporters a bit more than just telling them to "go build your own version and debug it".

      I know I'm far from the only person who encounters this slew of assertion failures on Linux, but most of my colleagues who encounter such errors just prefer to switch IDE rather than receive such a cold reception when trying to report bugs.

      I will meanwhile see if I can find a set of files and search terms that reproduces this issue reliably.

       
  • Teodor Petrov

    Teodor Petrov - 2016-02-26

    For debug build:
    1. download the source
    2. ./configure --enable-debug --prefix=/somewhere/not/in/usr
    3. install all missing dev libraries
    4. repeat 3
    5. make && make install

    BTW: A simpler thing to do is to just install the debug symbols with your package manager. Then use the debugger (gdb /usr/bin/codeblocks) to see if it provides more info.
    It will be good if you can tell us the value of the parameter possibleEncoding in the DetectEncodingAndConvert function.

    About cold reception: What do you mean by this? Are you expecting us to fix random bugs just by explanation and incomplete backtrace? Without a way to reproduce them?

    Lastly: keep in mind that you're using a combination of cb and wx that is not fully supported officially; yes using wx3 at the moment is experimental and there are lots of bugs.

     
  • Dante Igashu

    Dante Igashu - 2017-02-10

    Hello! :D
    I get the same error code (3031) I've been working with code blocks 16.01 on Antergors and then changed to code blocks svn from the Arch Linux AUR version 11002 and they have the same issues. The most annoying one is this one, every time I add a new empty file (ctrl + shift +n) and name it like "File.h" or "File.cpp" (I used to get an empty extension, now I automatically get the new File to end with a ".ads" extension) or everytime I save changes. It happens with every project I create on c++ (haven't checked if the same happens for C projects as I don't use it). Also (or Additionally) if you want me to, I can open a new thread as this one is kind of old and also I get other bugs (I supose it is due to what was mentiones before, the Linux version seems to be partially suported) like being unable to open the "Management" window (shift + F2) or the "Logs & others" window (F2) but after going to view->Perspectives->Code::Blocks default (when already using the default). This is exactly what I get with the (3031) issue:

    Backtrace:
    ASSERT INFO:
    ./src/common/strconv.cpp(3031): assert "Assert failure" failed in wxCSConv(): invalid encoding value in wxCSConv ctor

    BACKTRACE:
    [1] wxCSConv::wxCSConv(wxFontEncoding)
    [2] FileManager::WriteWxStringToFile(wxFile&, wxString const&, wxFontEncoding, bool)
    [3] FileManager::Save(wxString const&, wxString const&, wxFontEncoding, bool)
    [4] cbEditor::Save()
    [5] cbEditor::SaveAs()
    [6] wxStringTokenizer::~wxStringTokenizer()
    [7] wxAppConsoleBase::CallEventHandler(wxEvtHandler, wxEventFunctor&, wxEvent&) const
    [8] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler
    , wxEvent&)
    [9] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler)
    [10] wxEvtHandler::TryHereOnly(wxEvent&)
    [11] wxEvtHandler::DoTryChain(wxEvent&)
    [12] wxEvtHandler::ProcessEvent(wxEvent&)
    [13] wxWindowBase::TryAfter(wxEvent&)
    [14] wxWindowBase::TryAfter(wxEvent&)
    [15] wxWindowBase::TryAfter(wxEvent&)
    [16] wxMenuCmd::Exec(wxObject
    , wxEvtHandler)
    [17] wxKeyBinder::OnChar(wxKeyEvent&, wxEvtHandler
    )
    [18] wxAppConsoleBase::CallEventHandler(wxEvtHandler, wxEventFunctor&, wxEvent&) const
    [19] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler
    , wxEvent&)
    [20] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler)
    [21] wxEvtHandler::TryHereOnly(wxEvent&)
    [22] wxEvtHandler::ProcessEventLocally(wxEvent&)
    [23] wxEvtHandler::ProcessEvent(wxEvent&)
    [24] wxEvtHandler::SafelyProcessEvent(wxEvent&)
    [25] g_closure_invoke
    [26] g_signal_emit_valist
    [27] g_signal_emit
    [28] gtk_window_propagate_key_event
    [29] g_closure_invoke
    [30] g_signal_emit_valist
    [31] g_signal_emit
    [32] gtk_propagate_event
    [33] gtk_main_do_event
    [34] g_main_context_dispatch
    [35] g_main_loop_run
    [36] gtk_main
    [37] wxGUIEventLoop::DoRun()
    [38] wxEventLoopBase::Run()
    [39] wxAppConsoleBase::MainLoop()
    [40] wxEntry(int&, wchar_t
    *)
    [41] __libc_start_main

    I checked the above answer (what seems to be a possible solution), but didn't get what Teodor Petrov tried to say, I don't understand what has to be done (sorry, I am still a newbie)

    For debug build:
    1. download the source
    2. ./configure --enable-debug --prefix=/somewhere/not/in/usr
    3. install all missing dev libraries
    4. repeat 3
    5. make && make install

    also don't know if I would have to do the same thing, as I get the error in a different scenario.

    If there's anything I can help with, I will try to do it (as I have not much experience).
    I also use other IDE's but code blocks feels more confortable for my coding style, but I hope this issues can be solved.

    PS: The code works just fine if you build it and compile it. I have no idea what those errors are caused by if code works just fine.

    THANKS in advance!

     

    Last edit: Dante Igashu 2017-02-10
  • Teodor Petrov

    Teodor Petrov - 2017-02-10
    1. Please don't post about multiple issue in a single ticket.
    2. c::b works fine on linux as long as wx2.8 is used, when wx3.x is used there are (more) problems - some are known some aren't, but they are getting fixed when as soon as they are found and a dev is able to reproduce them.
    3. What are the exact steps to reproduce the wxCSConv problem? Does it happen every time? Can you provide a sample project and the exact steps to reproduce it?
    4. I'm getting the .ads problem on my works centos 6 linux and not on my home gentoo, which is strange... If it is such a problem please open another ticket!
     
    • Dante Igashu

      Dante Igashu - 2017-02-12

      Thanks for your help!
      Sure, I won't post multiple issues again, sorry.

      I suppose I have the latest wx version.
      Not sure about what wx are you talking but I have wxgtk version 3.0.2 - 6 and wxpython 3.0.2 - 2, in case you need this info.

      About the sample and the steps to reproduce it:

      Well, it is so simple that I am not sure if it is going to be of any help. Working on any C++ project, even if is completely new, I add an empty file (either way, using ctrl + shift +n or by going File->New->Empty File) CB asks me for the file name (wich usually appears as "Untittled" but I now get "Untitled.ads") I change it to something like "File.h" press the save button or ENTER and then I get the mentioned error "./src/common/strconv.cpp(3031): assert "Assert failure" failed in wxCSConv(): invalid encoding value in wxCSConv ctor", then I'm given two options: 1. stop 2. continue. If I click stop, codeblocks gets closed, but if I press continue, it seems to keep working just fine.

      It doesn't seem to cause any noticeable problem and I hope it actuallu doesn't, it just seems to be an annoying error message that is itself an error. I can just uncheck the "show this dialog next time" box and I supposed I won't see it again, at least for a while. So it more like I wanted to make sure it doesn't crate a bigger issue for myself and help the community at the same time. Yes, it happens every single time I do that, no exceptions.

      One more thing is that they just started happening a couple month ago, I don't know when it started (unfortunately) as I didn't use it for a time, and other pieces of softare kept getting updates, not sure if the 3.x version of wx was already installed before the issues began.

      About the .ads and the problem with the Management and Log & others windows issue, I don't know if there's any connection with the wxCSConv problem, but I guess I will be opening a new ticket for each if they haven't been reported already.

      Thanks a lot again! : )

      PS:

      I forgot to add that it happens (the wxCSConv error) everytime I save changes. Sorry.

       

      Last edit: Dante Igashu 2017-02-12
  • TSM

    TSM - 2017-10-26

    So how's bugfixing going? Those asserts are really annoying and they're not fixed even in svn trunk.
    I guess the problem is quite simple for anybody who's familiar with wxWidgets (not me): some cbEditor object contains wxFONTENCODING_DEFAULT in m_pData->m_encoding, then it gets transfered to other functions when you try to save file (as you can see in the traceback) and finally crashes in wxCSConv constructor because wxFONTENCODING_DEFAULT isn't valid constructor argument. I guess you actually need to substitute that default encoding (e.g. UTF-8) before calling the constructor, but i'm not guru so I can't say for sure.
    Maybe it's wxWidgets problem and not C::B's?

     
  • Teodor Petrov

    Teodor Petrov - 2017-10-26

    There is an easy work around for this problem -> set the encoding to something that is not default in the settings. Mine was set to utf8 and thus I didn't see this problem. Now I see it when I've set the encoding to default.

     
  • Teodor Petrov

    Teodor Petrov - 2017-10-27
    • status: open --> fixed
    • assigned_to: Teodor Petrov
     
  • Teodor Petrov

    Teodor Petrov - 2017-10-27

    Fixed in rev 11219. Please test and report if there are more problems.

     
    • TSM

      TSM - 2017-10-29

      Yep, fixed for me.

       
  • Teodor Petrov

    Teodor Petrov - 2017-11-04

    @Riot: It seems that this topic contains reports for 3 different problems and I've fixed only two of them, but not the original problem. Are you still able to reproduce the original problem? Can you clarify the steps a bit? Do you have a file that causes it? Does it happen with the project from ticket [#338]?

     

    Related

    Tickets: #338

    • Riot

      Riot - 2017-11-06

      The problem as per ticket #338 still recurs as of version SVN 11217. Have updated there with a screenshot of the latest backtrace.

      The issue here still recurs as of that version, too - here's the backtrace:

      In this case, to reproduce, I selected a word I knew would appear in a number of files ("erase") and did a search-replace to change it to some arbitrary test string, for all files in project, as per these settings:

      This happens with the project file as attached to the other ticket. Unfortunately, for a number of reasons, I can't share the complete code. If you're totally unable to reproduce, I can try to produce a minimal test case.

       
      • Teodor Petrov

        Teodor Petrov - 2017-11-06

        It will be easier for me if you upload a minimal test case which could be used to reproduce the problem.

         
  • Teodor Petrov

    Teodor Petrov - 2017-11-06
    • status: fixed --> open
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.