Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal crashes when launched by start /MAX #17161

Open
pejons opened this issue Apr 30, 2024 · 2 comments
Open

Terminal crashes when launched by start /MAX #17161

pejons opened this issue Apr 30, 2024 · 2 comments
Labels
Area-DefApp Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Attention The core contributors need to come back around and look at this ASAP. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.

Comments

@pejons
Copy link

pejons commented Apr 30, 2024

Windows Terminal version

1.19.10821.0

Windows build number

10.0.22631.0

Other Software

No response

Steps to reproduce

Create the following batch file:

@echo off

REM restart maximized if not already
if not "%1" == "max" start /MAX cmd /c %0 max & exit /b

echo Beep boop
timeout /t 20

With all Terminal windows closed, double-click to execute the script.

Expected Behavior

Terminal window should open maximized and display the 20 second countdown.

Actual Behavior

You will see a terminal window pop up momentarily then exit, rather than waiting the 20 seconds.

Open a Terminal window in the background, then double-click to execute the script again. You will see a maximized terminal window pop up showing the countdown from 20 seconds (as expected).

Feedback Hub link: https://aka.ms/AAq7vl0

@pejons pejons added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Apr 30, 2024
@carlos-zamora carlos-zamora added Product-Terminal The new Windows Terminal. Priority-2 A description (P2) Area-DefApp and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels May 1, 2024
@carlos-zamora carlos-zamora added this to the Terminal v1.22 milestone May 1, 2024
@zadjii-msft
Copy link
Member

Thanks for filing!

@echo off

REM restart maximized if not already
if not "%1" == "max" start /MAX cmd /c %0 max

echo Beep boop
timeout /t 20

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label May 1, 2024
@pejons
Copy link
Author

pejons commented May 1, 2024

Do you have any memory if this worked in 1.18 (or earlier)?

No, I started on the project where I ran into this very recently.

Does something similar happen with the batch script in #14499?

No, that script seems to work as expected.

Does this work if you remove the /max

Yes, the following script works without issue (except it doesn't maximize, of course)

@echo off

REM restart maximized if not already
if not "%1" == "max" start cmd /c %0 max & exit /b

echo Beep boop
timeout /t 20

or if you change it to something like

Yes, that also works as expected (one non-maximized terminal window opens, followed by a maximized terminal window).


I also tried messing with the rending options, none of which made a difference:

  • AtlasEngine enabled, hardware rendering
  • AtlasEngine enabled, software rendering
  • AtlasEngine disabled, software rendering

But with AtlasEngine disabled and hardware rendering, it seems like it takes longer to crash. And about 10% of the time, it wouldn't crash at all. Feels kinda like a race condition.

Finally, here is the original script which I minimized into the reproduction example. It doesn't crash, but does fail to minimize.
If I REM out the call :echo-align center line, it will crash as well.

@echo off

REM restart maximized if not already
if not "%1" == "max" start /MAX cmd /c %0 max & exit /b

title 202020

REM blank lines to center text vertically
for /L %%a in (1, 1, 30) do (
    echo.
)

REM message centered horizontally
call :echo-align center "look away for 20 seconds, press ESC to dismiss"

REM echo look away for 20 seconds, press ESC to dismiss

REM blank lines to push timeout countdown to bottom
for /L %%a in (1, 1, 20) do (
    echo.
)

timeout /t 20

:echo-align <align> <text>
	setlocal EnableDelayedExpansion
	(set^ tmp=%~2)
	if defined tmp (
		set "len=1"
		for %%p in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do (
			if "!tmp:~%%p,1!" neq "" (
				set /a "len+=%%p"
				set "tmp=!tmp:~%%p!"
			)
		)
	) else (
		set len=0
	)

	for /f "skip=4 tokens=2 delims=:" %%i in ('mode con') do (
		set /a cols=%%i
		goto loop_end
	)
	:loop_end

	if /i "%1" equ "center" (
		set /a offsetnum=^(%cols% / 2^) - ^(%len% / 2^)
		set "offset="
		for /l %%i in (1 1 !offsetnum!) do set "offset=!offset! "
	) else if /i "%1" equ "right" (
		set /a offsetnum=^(%cols% - %len%^)
		set "offset="
		for /l %%i in (1 1 !offsetnum!) do set "offset=!offset! "
	)

	echo %offset%%~2
	endlocal

	exit /b

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-DefApp Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Attention The core contributors need to come back around and look at this ASAP. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

3 participants