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

Abort trap: 6 #660

Closed
claudio-destro opened this issue Jan 23, 2016 · 13 comments
Closed

Abort trap: 6 #660

claudio-destro opened this issue Jan 23, 2016 · 13 comments

Comments

@claudio-destro
Copy link

Hi guys

Chatted with @reconbot about the following error I got in my code:

Assertion failed: (loop->watchers[w->fd] == w), function uv__io_stop, file ../deps/uv/src/unix/core.c, line 864.
Abort trap: 6

it seems to be random... I got it in my library flashmagic.js branch develop.

please run cli.ts with subcommand "ping" but I think you will need an NXP LPC hardware...

# ./bin/flashmagic.js -P <your_port> ping

I get the error after attempting to close and reopen a given serial port with different baud rate (see last lines in src/Handshake.ts): 9600 -> 115200.


Attempting to reproduce the issue I wrote the following code in plain javascript: it fails fast sometimes with "Error: Serialport not open" (-> uncomment on('data')), sometimes with "Error: Cannot open /dev/tty.usbserial-FTBTBAAW".

It seems like the close/open functions do not work as expected.

var com = require('serialport');

var path = process.argv[2]

var serialport = openCom(path, 9600);
var count = 1;

(function loop() {
  // serialport.on('data', function(data) {
  //   console.log(data);
  // });
  serialport.open(function(error) {
    if (error) { console.error(error); throw error;}
    serialport.write('?', function(error) {
      if (error) { console.error(error); throw error;}
      serialport.drain(function(error) {
        if (error) { console.error(error); throw error;}
        serialport.close(function(error) {
          if (error) { console.error(error); throw error;}
          console.log('closed ' + count++);
          serialport = openCom(path, 115200);
          process.nextTick(loop);
        }); // close
      }); // drain
    }); // write
  });
})();

function openCom(path, baud) {
  return new com.SerialPort(path, {
      baudRate: baud,
      stopBits: 1,
      parity: 'none',
      parser: com.parsers.readline('\r\n')
    }, false); // open later
}

/*
$ uname -a
Darwin iMac-di-Claudio.lan 15.2.0 Darwin Kernel Version 15.2.0: Fri Nov 13 19:56:56 PST 2015; root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
$ node -v
v5.4.0
*/
@claudio-destro
Copy link
Author

See this
nodejs/node#3604

@reconbot
Copy link
Member

Can you confirm your platform? I think this is related to #670

@claudio-destro
Copy link
Author

Confirmed. I think it is related to open/close port too: actually I have to use only one port at a time.

Inviato da iPad

Il giorno 27 mar 2016, alle ore 06:16, Francis Gulotta [email protected] ha scritto:

Can you confirm your platform? I think this is related to #670


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

@reconbot
Copy link
Member

I meant, is this Linux on an embedded device, and if so, which one?

@claudio-destro
Copy link
Author

Nope

As written in the code, it is OS X with node 5.4

Claudio

Il giorno 27 mar 2016, alle ore 17:11, Francis Gulotta [email protected] ha scritto:

I meant, is this Linux on an embedded device, and if so, which one?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

@reconbot
Copy link
Member

reconbot commented Apr 6, 2016

@claudio-destro We fixed a ton of bugs in our latest beta specifically ones addressing this issue on osx.

#733 Please try it out [email protected] and report back!

@claudio-destro
Copy link
Author

Ok I will try it out!

Inviato da iPhone

Il giorno 06 apr 2016, alle ore 19:20, Francis Gulotta [email protected] ha scritto:

@claudio-destro We fixed a ton of bugs in our latest beta specifically ones addressing this issue on osx.

#733 Please try it out [email protected] and report back!


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@reconbot
Copy link
Member

Did it work out? We've released [email protected].

@claudio-destro
Copy link
Author

I didn't have enough time... Sorry

I did a little test yesterday night and seemed working. I will try the new release.

Claudio

Inviato da iPhone

Il giorno 11 apr 2016, alle ore 03:22, Francis Gulotta [email protected] ha scritto:

Did it work out? We've released [email protected].


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@reconbot
Copy link
Member

I'm going to close this issue due to it's age, but if you'd like to continue with it feel free to reopen.

@reconbot
Copy link
Member

reconbot commented Nov 9, 2016

Can you show me the crashing code? And can you tell me what version you're
running.


Francis Gulotta
[email protected]

On Wed, Nov 9, 2016 at 3:15 PM, Luc DeTellis [email protected]
wrote:

I was getting the "Abort trap: 6" crash. After some experimenting I found
that I was sending writes one immediately after another, which was
apparently too fast for serialport to handle.

Here's the setTimeout I had to add:

serial.write(output + '\n', function(err) {
if (err) return log.error('serialport', err);
setTimeout(function() {
if (cue.length === 0) {
canSend = true;
} else {
write(cue.shift());
}
}, 0);
});


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#660 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABlbq837CmEB5dEkI_3eRqXeZgDp84Lks5q8in_gaJpZM4HK9y2
.

@lucdetellis
Copy link

lucdetellis commented Nov 9, 2016

@reconbot Sorry I deleted my original comment, I found a better solution than using a setTimeout.

Here's my original code if you're interested:

var write = function(output) {
  if (serial.isOpen) {
    serial.write(output + '\n', function(err) {
      if (err) return log.error('serialport', err);
      if (cue.length === 0) {
        canSend = true;
      } else {
        write(cue.shift());
      }
    });
  }
};

var send = function(output) {
  if (canSend === true) {
    canSend = false;
    write(output);
  } else {
    cue.push(output);
  }
};

// EDIT: Only 2 writes were enough to trigger "Abort trap: 6"
send('1,0,0,0');
send('exec');

I fixed the "Abort trap: 6" error by adding serial.drain() before each write:

var write = function(output) {
  serial.write(output + '\n', function(err) {
    if (err) return log.error('serialport', err);
    serial.drain(function(err) {
      if (err) return log.error('serialport', err);
      if (cue.length === 0) {
        canSend = true;
      } else {
        write(cue.shift());
      }
    });
  });
};

@reconbot
Copy link
Member

reconbot commented Nov 9, 2016

There isn't an upper limit on how many writes you can do in sequence, so
I'd like to get to the bottom of this.


Francis Gulotta
[email protected]

On Wed, Nov 9, 2016 at 4:00 PM, Luc DeTellis [email protected]
wrote:

@reconbot https://github.com/reconbot Sorry I deleted my original
comment, I found a better solution than using a setTimeout.

Here's my original code if you're interested:

var write = function(output) {
if (serial.isOpen) {
serial.write(output + '\n', function(err) {
if (err) return log.error('serialport', err);
if (cue.length === 0) {
canSend = true;
} else {
write(cue.shift());
}
});
}
};

var send = function(output) {
if (canSend === true) {
canSend = false;
write(output);
} else {
cue.push(output);
}
};

send('a lot of things at once');
...
send('more things');

I fixed the "Abort trap: 6" error by adding serial.drain() before each
write:

var write = function(output) {
serial.write(output + '\n', function(err) {
if (err) return log.error('serialport', err);
serial.drain(function(err) {
if (err) return log.error('serialport', err);
if (cue.length === 0) {
canSend = true;
} else {
write(cue.shift());
}
});
});
};


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#660 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABlblEXHQ8CYIAJVZDMffnj0VmdL9U3ks5q8jSFgaJpZM4HK9y2
.

@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants