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

Stdin.echoMode is not reseted on crash #17743

Closed
DartBot opened this issue Mar 24, 2014 · 12 comments
Closed

Stdin.echoMode is not reseted on crash #17743

DartBot opened this issue Mar 24, 2014 · 12 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DartBot
Copy link

DartBot commented Mar 24, 2014

This issue was originally filed by @Fox32


What steps will reproduce the problem?

  1. Set Stdin.echoMode to false
  2. Crash your application

What is the expected output? What do you see instead?

Echo mode is off. I would expect that it is enabled again. If the application exits without a crash, the echo mode is reseted.

What version of the product are you using? On what operating system?
Dart Editor version 1.3.0.dev_06_01 (DEV)
Dart SDK version 1.3.0-dev.6.1
Windows 8.1 64bit, Ubuntu, OSX

@DartBot
Copy link
Author

DartBot commented Mar 24, 2014

This comment was originally written by @Fox32


My fault, it seems to work on Windows. But I have still issueson OSX and Linux. I use the following test program:

import 'dart:io';

void main(List<String> arguments) {
  stdin.echoMode = false;
  // Case 1: Not reseted
  return;
  // Case 2: Not reseted
  throw new ArgumentError();
  // Case 3: Not reseted
  exit(0);
  // Case 4, using Ctrl+C to exit the program: Reseted!
  new Future.delayed(const Duration(milliseconds: 50000), () {
   print('test');
  });
}

@floitschG
Copy link
Contributor

Added Area-IO, Triaged labels.

@andersjohnsen
Copy link

I just tested this in python where I see the same behavior with http://docs.python.org/2/library/curses.html.

I'm not sure what the right thing to do is. While I agree that it's unexpected, it's needed if a person wants to write a tool that simply disables echo and returns.

@DartBot
Copy link
Author

DartBot commented Mar 25, 2014

This comment was originally written by @Fox32


It would be possible to reset it myself on normal exit as I only have two exit points. On abnormal exit I could use the Zone interfaces to catch all unhandled errors and disable it. But a global handler is annoying during development. Something like a global finally block isn't available right?

@andersjohnsen
Copy link

Not that I'm aware of. I'll discuss with the library team if they have any suggestions for this scenario.

@andersjohnsen
Copy link

So, we're in the process of adding some ways of recovering, by running the program in a child isolate. However, we are still early in the process and the API is not yet in place.

Have you tried encapsulating the program in another process?

@DartBot
Copy link
Author

DartBot commented Mar 25, 2014

This comment was originally written by @Fox32


Thanks for that idea, I haven't thought about another process or isolate yet. I will look into that.

@DartBot
Copy link
Author

DartBot commented Mar 29, 2014

This comment was originally written by @Fox32


I checked the possible solutions:
A own process is not "possible" as it would be very difficult to work with during development. Perfect would be an isolate based solution. My first steps work well for normal exit, but the isolate library seems to miss a good way of handling crashes in the child isolate (maybe a zone that sends back a message?). After my first steps with isolates, I thought it would be nice to name isolates for development, that would make debugging much easier while working with multiple isolates (Something like http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx, only available if debugger enabled?). Here is my current code:

void main(List<String> arguments) {
  final previousEchoMode = stdin.echoMode;

  Isolate.spawn(run, arguments).then((i) {
    final rp = new ReceivePort();

    i.addOnExitListener(rp.sendPort);

    return rp.single.then((_) {
      // Not called if the isolate terminates in a abnormal way (crash)
      stdin.echoMode = previousEchoMode;
    });
  });
}

void run(List<String> arguments) {
 // My old main code...
}

@kevmoo
Copy link
Member

kevmoo commented May 14, 2014

Removed Area-IO label.
Added Library-IO label.

@devoncarew
Copy link
Member

Issue #17746 has been merged into this issue.

@DartBot
Copy link
Author

DartBot commented Apr 10, 2015

This comment was originally written by @Fox32


I just want to mention that is now possible to workaround this issue with addOnExitListener, works fine.

@kevmoo kevmoo added the area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. label Jun 16, 2015
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@natebosch
Copy link
Member

I think addOnExitListener is the expected workaround.

@lrhn or @zanderso - please reopen if you think we should handle resetting echo mode automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants