Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

React editor crashes when there is a null byte in the file #2391

Closed

Description

@luto

echo "\0" > nullbytefile && atom nullbytefile

crashes the textfield and opens the console, with a bunch of TypeError: Cannot read property 'textContent' of null errors, probably because it can't initialize the editor itself and tries it access it anyways. The original error is not shown, as far as I can tell.

TypeError: Cannot read property 'textContent' of null
  at [object Object].module.exports.React.createClass.measureCharactersInLine (/usr/local/share/atom/resources/app/src/lines-component.js:347:43)
  at [object Object].boundMethod [as measureCharactersInLine] (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1434:21)
  at [object Object].module.exports.React.createClass.measureCharactersInNewLines (/usr/local/share/atom/resources/app/src/lines-component.js:320:30)
  at [object Object].boundMethod [as measureCharactersInNewLines] (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1434:21)
  at [object Object].module.exports.React.createClass.componentDidUpdate (/usr/local/share/atom/resources/app/src/lines-component.js:95:21)
  at ReactMountReady.mixInto.notifyAll (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactMountReady.js:69:18)
  at ReactReconcileTransaction.ON_DOM_READY_QUEUEING.close (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactReconcileTransaction.js:87:26)
  at ReactReconcileTransaction.Mixin.closeAll (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/Transaction.js:242:42)
  at ReactReconcileTransaction.Mixin.perform (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/Transaction.js:175:16)
  at [object Object].ReactComponent.Mixin.performUpdateIfNecessary (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactComponent.js:478:19)
  at [object Object].ReactCompositeComponentMixin.performUpdateIfNecessary (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1157:51)
  at Object.enqueueUpdate (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactUpdates.js:107:15)
  at [object Object].ReactCompositeComponentMixin.forceUpdate (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1379:18)
  at [object Object].module.exports.React.createClass.requestUpdate (/usr/local/share/atom/resources/app/src/editor-component.js:917:21)
  at [object Object].boundMethod [as requestUpdate] (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactCompositeComponent.js:1434:21)
  at [object Object].module.exports.React.createClass.componentDidMount (/usr/local/share/atom/resources/app/src/editor-component.js:175:19)
  at ReactMountReady.mixInto.notifyAll (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactMountReady.js:69:18)
  at ReactReconcileTransaction.ON_DOM_READY_QUEUEING.close (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactReconcileTransaction.js:87:26)
  at ReactReconcileTransaction.Mixin.closeAll (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/Transaction.js:242:42)
  at ReactReconcileTransaction.Mixin.perform (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/Transaction.js:175:16)
  at [object Object].ReactComponent.Mixin.mountComponentIntoNode (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactComponent.js:537:19)
  at Object._renderNewRootComponent (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactMount.js:309:25)
  at Object.ReactMount.renderComponent (/usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactMount.js:359:32)
  at ReactEditorView.module.exports.ReactEditorView.afterAttach (/usr/local/share/atom/resources/app/src/react-editor-view.js:81:30)
  at callAttachHook (/usr/local/share/atom/resources/app/node_modules/space-pen/lib/space-pen.js:343:107)
  at [object Object].jQuery.fn.(anonymous function) [as append] (/usr/local/share/atom/resources/app/node_modules/space-pen/lib/space-pen.js:359:9)
  at PaneView.module.exports.PaneView.onActiveItemChanged (/usr/local/share/atom/resources/app/src/pane-view.js:297:24)
  at /usr/local/share/atom/resources/app/src/pane-view.js:3:61
  at /usr/local/share/atom/resources/app/node_modules/emissary/lib/emitter.js:133:30
  at Array.forEach (native)
  at Behavior.module.exports.Emitter.emit (/usr/local/share/atom/resources/app/node_modules/emissary/lib/emitter.js:132:47)
  at Behavior.module.exports.Behavior.emit (/usr/local/share/atom/resources/app/node_modules/emissary/lib/behavior.js:44:38)
  at Behavior.module.exports.Signal.emitValue (/usr/local/share/atom/resources/app/node_modules/emissary/lib/signal.js:82:19)
  at Pane.module.exports.Model.set (/usr/local/share/atom/resources/app/node_modules/theorist/lib/model.js:166:21)
  at Pane.accessor.set (/usr/local/share/atom/resources/app/node_modules/theorist/lib/model.js:57:23)
  at Pane.module.exports.Pane.addItem (/usr/local/share/atom/resources/app/src/pane.js:189:25)
  at Pane.module.exports.Pane.activateItem (/usr/local/share/atom/resources/app/src/pane.js:174:14)
  at /usr/local/share/atom/resources/app/src/workspace.js:214:16
  at _fulfilled (/usr/local/share/atom/resources/app/node_modules/q/q.js:787:54)
  at self.promiseDispatch.done (/usr/local/share/atom/resources/app/node_modules/q/q.js:816:30)
  at Promise.promise.promiseDispatch (/usr/local/share/atom/resources/app/node_modules/q/q.js:749:13)
  at /usr/local/share/atom/resources/app/node_modules/q/q.js:557:44
  at flush (/usr/local/share/atom/resources/app/node_modules/q/q.js:108:17)
  at process._tickCallback (node.js:605:11)
 /usr/local/share/atom/resources/app/src/workspace.js:223
Uncaught TypeError: Cannot read property 'textContent' of null /usr/local/share/atom/resources/app/src/lines-component.js:347
Uncaught TypeError: Cannot read property 'textContent' of null /usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactMountReady.js:69
Uncaught TypeError: Cannot read property 'textContent' of null /usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactMountReady.js:69
Uncaught TypeError: Cannot read property 'textContent' of null /usr/local/share/atom/resources/app/node_modules/react-atom-fork/lib/ReactMountReady.js:69

Activity

  1. izuzak commented on May 24, 2014

    @izuzak
    Contributor

    echo "\0" > nullbytefile && atom nullbytefile

    That's interesting -- I can't reproduce this on OSX with Atom 0.99.0-5b149bd 0.100.0-00987f3.

    $ hexdump test
    0000000 00 00 00 00 00 00 00 00 00 00 00               
    000000b
    
    $ atom test
    

    Atom starts normally and shows this:

    screen shot 2014-05-24 at 3 46 53 pm

    (it's not visible in the screenshot, but the cursor is on position 1,12 in the file -- so Atom recognizes there's something in the file)

    Which OS and version are you on @luto, and which version of Atom are you using?

  2. luto commented on May 24, 2014

    @luto
    Author

    Ooops, I knew that I forgot something..

    Linux luto-portable 3.14.4-1-ARCH #1 SMP PREEMPT Tue May 13 16:41:39 CEST 2014 x86_64 GNU/Linux

    00987f3

  3. nathansobo commented on Jun 11, 2014

    @nathansobo
    Contributor

    This is related to not being able to measure characters properly, and is a corner case related to your content. Could you share an example of the content that produces the problem?

  4. luto commented on Jun 11, 2014

    @luto
    Author

    Like I wrote, any file with a null-byte => echo "\0" > nullbytefile.

    For realworld-files: I tried to open a random cache-file.. which crashed the editor. I then looked deeper, narroing down which content exactly caused this, because a bug-report like "hey! this 20 mb file crashes atom! fix it!" is broing.

  5. nathansobo commented on Jun 11, 2014

    @nathansobo
    Contributor

    I'll try again to reproduce it. I appreciate your patience with this. 🙇

  6. luto commented on Jun 11, 2014

    @luto
    Author

    trying this.

  7. nathansobo commented on Jun 11, 2014

    @nathansobo
    Contributor

    Thanks for helping us out with this!

    @izuzak I'm still a bit concerned about measurement errors with multibyte characters, because I really need to do a pass on that and make sure all our logic makes sense. If you have time and desire to try to break Atom with some international characters, that could be helpful.

  8. luto commented on Jun 11, 2014

    @luto
    Author

    Thank you!

    The crash is now fixed, but I am not really sure about this:

    echo "aaa\0\0\0\0bbbbccb" > nullbytefile

    1. Move cursor to the 2nd line
    2. press left => cursor goes up one line, to the very right char
    3. press left again
      • expected: cursor is between c and b
      • actual: cursor is still after b
    4. press left 3 more times (3+1 nullbytes in total) actually brings you to c

    So the null bytes are now hidden to the user, but still "visible" to the cursor-movement.

    This would be a bit more work, and probably a seperate issue, but I really like what notepad++ is doing with special characters:
    image
    It does that with a wide range of characters, like BEL, LF, CR and so on.

  9. nathansobo commented on Jun 11, 2014

    @nathansobo
    Contributor

    Yeah, that seems like a great approach. It's going to require some reworking of our rendering, so I'd like to do it once we complete the switch to React.

  10. izuzak commented on Jun 11, 2014

    @izuzak
    Contributor

    @izuzak I'm still a bit concerned about measurement errors with multibyte characters, because I really need to do a pass on that and make sure all our logic makes sense. If you have time and desire to try to break Atom with some international characters, that could be helpful.

    @nathansobo Sure! Just to make sure -- you're interested in problems which cause exceptions, or problems which cause strange cursor movement, as described in #1849?

  11. nathansobo commented on Jun 11, 2014

    @nathansobo
    Contributor

    Exceptions are my primary concern for now. I want to do a pass for gracefully handling multibyte characters later, because I know there's plenty of issues.

  12. kingjr commented on May 4, 2015

    @kingjr

    Yeah, that seems like a great approach. It's going to require some reworking of our rendering, so I'd like to do it once we complete the switch to React.

    @nathansobo @luto Have you made progress on making the nulltype chars visible? I'm having weird errors where copy and paste introduces null types, which I then need to remove with a bash command:

    tr < my_file.py -d '\000' > my_file2.py
    

    Thanks.

  13. lock commented on Jan 22, 2019

    @lock

    This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!

  14. locked as resolved and limited conversation to collaborators on Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglinux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions