From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 62F053858402; Tue, 23 Nov 2021 10:29:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62F053858402 From: "aburgess at redhat dot com" To: gdb-prs@sourceware.org Subject: [Bug python/28620] logging/output redirect interaction between python and stepping commands is broken (and sometimes segfaults) Date: Tue, 23 Nov 2021 10:29:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: python X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aburgess at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on bug_status cc everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Nov 2021 10:29:31 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28620 Andrew Burgess changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-11-23 Status|UNCONFIRMED |NEW CC| |aburgess at redhat dot com Ever confirmed|0 |1 --- Comment #1 from Andrew Burgess --- This problem can be simplified to just doing: (gdb) python gdb.execute("set logging on", False, True) (gdb) set logging off The second 'True' in the gdb.execute is critical for reproducing this bug. What happens is that in execute_control_commands_to_string (cli/cli-script.= c) we redirect all of the gdb_std* streams into a string_file, then we execute= the command. The command in question is 'set logging on', this ends up in cli_interp_base::set_logging (cli/cli-interp.c) where the values of the gdb_std* streams are stashed away and then replaced with new logging specif= ic values. At this point we have already gone wrong, we think we are writing to a string_file, but we're now writing to the log file instead. We then return to execute_control_commands_to_string where we restore the o= ld values of the gdb_std* streams, this restores the write to the terminal streams, we've now gone wrong for a second time - logging should be on, but instead we are writing to the terminal. The string_file is destroyed as it goes out of scope. Finally, when we execute the 'set logging off' we end up back in cli_interp_base::set_logging where we restore the stashed gdb_std* stream values, in our case, the stashed values are the now deleted, string_file stream. This is the third time we go wrong. At some future point we try to write to the stream, the contents of which a= re now undefined, at some point this usually triggers a segfault. --=20 You are receiving this mail because: You are on the CC list for the bug.=