Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Exit code -1073740791 (0xC0000409) when I input a string in QTextEdit



  • I've this function that read a text file and input the content in a QTextEdit (it works on thread mode). The problem is that if I call much times this function the IDLE return this exit code:

    Process finished with exit code -1073740791 (0xC0000409)

    I was reading about this exit code and is something about: "0xC0000409 means stack buffer overflow as seen in this windows help link. ... It is probable that you are writing something past the end of a buffer, or writing something to a pointer that is pointing to the wrong place."

    This exite code only happens when I try to input the text in the QTextEdit, I'm 100% about this. There is a way to fix it?

    OS: Windows 10 Home 10.0.19042 Build 19042
    RAM: 8 GB
    Python: 3.8
    IDE: PyCharm

    def shell_control(self):
        # ALLOW THE QTEXTEDIT INPUT
        with open(f'bin/request/transfer/execute/{self.hselected}', 'w') as new_task:
            new_task.write('True')
            new_task.close()
    
        # TIME FOR WAIT THE STRING
        time.sleep(4)
    
        # GETTING THE STRING
        with open(f'bin/request/transfer/stdout/{self.hselected}', 'r') as get_output:
            command_output = get_output.read()
            get_output.close()
    
        # PRINT FOR DEBUG
        print(f'stdout -> {command_output}')
    
        # RETURN IF THE STRING IS NONE OR SOMETHING
        if command_output == '' or command_output == ' ' or command_output == 'None' or command_output == 'NoneNone' or command_output == None:
            with open(f'bin/request/transfer/stdout/{self.hselected}', 'w') as get_output:
                get_output.write('')
            return
    
        # CLEAR COME CHARACTERS OF STRING
        get_the_stdout = command_output
        get_the_stdout = get_the_stdout.replace("b' ", "")
        get_the_stdout = get_the_stdout.replace("b'", "")
        rmp2 = get_the_stdout[-1:]
        if rmp2 == "'" or rmp2 == '"':
            get_the_stdout = get_the_stdout.replace(rmp2, "")
        get_the_stdout = get_the_stdout.replace('\\n', '\n')
    
        #################################
        # INSERT THE STRING IN QPLAINTEXT
        #################################
    
        self.shell_host.insertPlainText(get_the_stdout)
    
        # CLEAR THE TEXTFILE
        with open(f'bin/request/transfer/stdout/{self.hselected}', 'w') as clear_file:
            clear_file.write('')
            clear_file.close()
    
        # ENABLE A WIDGET OF MY SOFTWARE
        self.active_shell_input = True
    

  • Lifetime Qt Champion

    @Black-Cat said in Exit code -1073740791 (0xC0000409) when I input a string in QTextEdit:

    self.shell_host.insertPlainText(get_the_stdout)

    Do you mean it happens in this line? Did you use debugger to check where exactly it happens? How does get_the_stdout look like if you print it to stdout?



  • @jsulm said in Exit code -1073740791 (0xC0000409) when I input a string in QTextEdit:

    Do you mean it happens in this line? Did you use debugger to check where exactly it happens? How does get_the_stdout look like if you print it to stdout?

    I'm using debugger exactly now, but I not experiment with the PyCharm debugger.

    This is the exacly value of the variable get_the_stdout:
    83fd0852-c384-457e-94df-a2ac021548b0-image.png

    or

    O volume na unidade C n\xc3\x86o tem nome.\n O N\xc2\xa3mero de S\xe2\x80\x9arie do Volume \xe2\x80\x9a 7C6B-DC0B\n\n Pasta de C:\\Users\\lsynote\\Desktop\n\n18/01/2021  10:51    <DIR>          .\n18/01/2021  10:51    <DIR>          ..\n13/01/2021  19:20               170 audio.py\n14/01/2021  19:34            12.271 client.py\n15/01/2021  23:04            11.153 client_backup.py\n18/01/2021  09:33            11.008 client_subprocess.py\n10/01/2021  16:40            10.281 c_backup.py\n18/01/2021  10:51                 0 output.txt\n17/01/2021  15:20         2.798.456 procexp.exe\n10/01/2021  02:50               910 simple.py\n11/01/2021  21:40             1.506 vstrm - Copia.py\n13/01/2021  21:45             2.067 vstrm.py\n15/01/2021  00:17    <DIR>          __pycache__\n              10 arquivo(s)      2.847.822 bytes\n               3 pasta(s)   453.384.409.088 bytes dispon\xc2\xa1veis\n
    


  • For the people with same problem try to replace the QTextEdit for a label + scroll area, it worked for me (Y)


Log in to reply