This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
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
Copy link
Copy link
Closed
Description
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
izuzak commentedon May 24, 2014
That's interesting -- I can't reproduce this on OSX with Atom
0.99.0-5b149bd0.100.0-00987f3.Atom starts normally and shows this:
(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?
luto commentedon May 24, 2014
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/Linux00987f3
nathansobo commentedon Jun 11, 2014
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?
luto commentedon Jun 11, 2014
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.
nathansobo commentedon Jun 11, 2014
I'll try again to reproduce it. I appreciate your patience with this. 🙇
luto commentedon Jun 11, 2014
trying this.
nathansobo commentedon Jun 11, 2014
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.
luto commentedon Jun 11, 2014
Thank you!
The crash is now fixed, but I am not really sure about this:
echo "aaa\0\0\0\0bbbbccb" > nullbytefilecandbbcSo 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:

It does that with a wide range of characters, like
BEL,LF,CRand so on.nathansobo commentedon Jun 11, 2014
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.
izuzak commentedon Jun 11, 2014
@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?
nathansobo commentedon Jun 11, 2014
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.
kingjr commentedon May 4, 2015
@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:
Thanks.
lock commentedon Jan 22, 2019
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!