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

Undocumented fs.FSWatcher::start() trips assertion in FSEventWrap::Start #17430

Closed
rdeforest opened this issue Dec 3, 2017 · 2 comments
Closed
Labels
fs Issues and PRs related to the fs subsystem / file system. macos Issues and PRs related to the macOS platform / OSX.

Comments

@rdeforest
Copy link

rdeforest commented Dec 3, 2017

  • Version: v8.2.1
  • Platform: Darwin a0999b17f5bd.ant.amazon.com 16.7.0 Darwin Kernel Version 16.7.0: Wed Oct 4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64 x86_64
  • Subsystem: fs

I randomly discovered the undocumented start() method on the FSWatcher prototype and started experimenting with it before finding out it's not documented. I created a repro script for you, shown in the "screenshot" following this paragraph.

2017-12-02 16:42:07
me@MyMac~/ws/lambda
$ node --version
v8.2.1

2017-12-02 16:42:10
me@MyMac~/ws/lambda
$ uname -a
Darwin laptop-hostname 16.7.0 Darwin Kernel Version 16.7.0: Wed Oct  4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64 x86_64

2017-12-02 16:42:25
me@MyMac~/ws/lambda
$ cat test.coffee
fs       = require 'fs'
util     = require 'util'

watcher  = null
put      = (text) -> (util.promisify (fs.writeFile)) 'test.dat', text
listener = (event, file) -> console.log {event, file}

put 'hello world'
  .then ->
    watcher = fs.watch 'test.dat', listener
    put "how you doin', world"
  .then ->
    watcher.start()
  .then ->
    watcher.close()

2017-12-02 16:42:31
me@MyMac~/ws/lambda
$ coffee test.coffee
{ event: 'change', file: 'test.dat' }
{ event: 'change', file: 'test.dat' }
/usr/local/Cellar/node/8.2.1/bin/node[42998]: ../src/fs_event_wrap.cc:117:static void node::(anonymous namespace)::FSEventWrap::Start(const FunctionCallbackInfo<v8::Value> &): Assertion `(wrap->initialized_) == (false)' failed.
 1: node::Abort() [/usr/local/bin/node]
 2: node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, char const*, int, v8::Local<v8::Value>*, node::async_context) [/usr/local/bin/node]
 3: node::(anonymous namespace)::FSEventWrap::Start(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
 4: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/local/bin/node]
 5: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node]
 6: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]
 7: 0x36bf65b840bd
Abort trap: 6

2017-12-02 16:42:44
me@MyMac~/ws/lambda
$ 

I was able to repro the bug in NodeJS v8.9.1 on Linux ec2-instance-hostname 4.4.20-0.1.fm.237.49.326.metal1.x86_64 #1 SMP Wed Sep 21 11:35:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

with a slightly different traceback. I'll try it on Windows when I get home.

I guess the issue is that the method exists at all? I hope this report is helpful. :)

@TimothyGu
Copy link
Member

TimothyGu commented Dec 3, 2017

Please try not to use any language other than vanilla JavaScript when reporting issues here.

Simplified JavaScript repro:

var fs = require('fs');
fs.watch('/dev/null', () => {}).start();

@TimothyGu
Copy link
Member

I guess the issue is that the method exists at all?

Indeed; though the fear when it comes to these things is that userland may already be using start, after a proper call to close for example. With that in mind, I've proposed a simple "don't crash" solution in #17432.

I hope this report is helpful. :)

Of course!

@mscdex mscdex added fs Issues and PRs related to the fs subsystem / file system. macos Issues and PRs related to the macOS platform / OSX. v8.x labels Dec 3, 2017
TimothyGu added a commit to TimothyGu/node that referenced this issue Dec 3, 2017
MylesBorins pushed a commit that referenced this issue Jan 8, 2018
MylesBorins pushed a commit that referenced this issue May 22, 2018
MylesBorins pushed a commit that referenced this issue Jun 14, 2018
rvagg pushed a commit that referenced this issue Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. macos Issues and PRs related to the macOS platform / OSX.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants