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

buffer: expose underlying buffer object always #8311

Closed

Conversation

thefourtheye
Copy link
Contributor

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

buffer

Description of change

If the Buffer object's length is zero, or equal to the underlying
buffer object's length, parent property returns undefined.

> new Buffer(0).parent
undefined
> new Buffer(Buffer.poolSize).parent
undefined

This patch makes the buffer objects to consistently expose the buffer
object via the parent property, always.

Fixes: #8266


cc @nodejs/buffer

If the Buffer object's length is zero, or equal to the underlying
buffer object's length, `parent` property returns `undefined`.

    > new Buffer(0).parent
    undefined
    > new Buffer(Buffer.poolSize).parent
    undefined

This patch makes the buffer objects to consistently expose the buffer
object via the `parent` property, always.

Fixes: nodejs#8266
@thefourtheye thefourtheye added the buffer Issues and PRs related to the buffer subsystem. label Aug 28, 2016
@trevnorris
Copy link
Contributor

LGTM. Though can we also move to deprecate .parent?

@addaleax
Copy link
Member

LGTM … what do you think on the semver-ness of this? It doesn’t seem like something that would reasonably break anybody’s code, but it does involve having to change the existing tests.

CI: https://ci.nodejs.org/job/node-test-commit/4812/
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/373/

@addaleax
Copy link
Member

CI looks okay, for CITGM… @thealphanerd are those known failures? (Also… so many DeprecationWarnings…)

@jasnell
Copy link
Member

jasnell commented Aug 29, 2016

+1 to a runtime deprecation on .parent, but that can be done as a separate semver-major PR. This one should be safe as a semver-minor.

@jasnell
Copy link
Member

jasnell commented Aug 29, 2016

LGTM

@addaleax addaleax added the semver-minor PRs that contain new features and should be released in the next minor version. label Aug 29, 2016
@addaleax addaleax mentioned this pull request Aug 29, 2016
2 tasks
@addaleax
Copy link
Member

addaleax commented Sep 5, 2016

@thefourtheye This is good to go, right? :)

@thefourtheye
Copy link
Contributor Author

@addaleax I would say so, as I have seen the vinyl-fs failure in few other runs as well. I thought it would be better if @thealphanerd or @phated could give GO/NO-GO here.

@phated
Copy link
Contributor

phated commented Sep 6, 2016

Pretty sure these are permission problems and the citgm needs to be fixed.

@jasnell
Copy link
Member

jasnell commented Sep 7, 2016

+1 to getting this landed :-)

@addaleax
Copy link
Member

addaleax commented Sep 8, 2016

Landed in c21458a

@addaleax addaleax closed this Sep 8, 2016
addaleax pushed a commit that referenced this pull request Sep 8, 2016
If the Buffer object's length is zero, or equal to the underlying
buffer object's length, `parent` property returns `undefined`.

    > new Buffer(0).parent
    undefined
    > new Buffer(Buffer.poolSize).parent
    undefined

This patch makes the buffer objects to consistently expose the buffer
object via the `parent` property, always.

Fixes: #8266
PR-URL: #8311
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
@thefourtheye thefourtheye deleted the buffer-parent-property branch September 10, 2016 12:19
@Fishrock123
Copy link
Contributor

Getting this trying to land on v6-staging:

/usr/bin/python tools/test.py --mode=release -J \
        addons doctool known_issues message pseudo-tty parallel sequential
=== release test-buffer ===                                                    
Path: parallel/test-buffer
b.length == 1024
c.length == 512
copied 512 bytes from b into c
copied 512 bytes from c into b w/o sourceEnd
copied 512 bytes from c into b w/o sourceStart
copied 512 bytes from b into c w/o targetStart
copied 256 bytes from end of b into beginning of c
copied 512 bytes from b trying to overrun c
copied 768 bytes from b into b
copied 512 bytes from b into c
test copy at negative sourceEnd
bytes written to buffer: 11
Create hex string from buffer
Create buffer from hex string
Try to slice off the end of the buffer
<Buffer 81 a3 66 6f 6f a3 62 61 72>
<Buffer 6f a3 62 61 72>
5
<Buffer 81 a3 66 6f 6f a3 62 61 72>
9
<Buffer 81 a3 66 6f>
4
<Buffer 81 a3 66 6f 6f a3 62 61 72>
9
<Buffer a3 66 6f>
3
<Buffer 66 6f>
2
<Buffer ff 61 62 ff>
<Buffer ff 61 62 63>
<Buffer ff 61 62 ff>
<Buffer ff ab cd ff>
<Buffer 61 00 ff ff>
<Buffer 61 00 ff ff>
<Buffer 61 00 ff ff>
<Buffer 61 00 ff ff>
uber: 'über'
f.length: 4     (should be 4)
f.length: 8     (should be 8)
f.length: 12     (should be 12)
bytes written to buffer: 4     (should be 4)
f.length: 8     (should be 8)
f.length: 12     (should be 12)
bytes written to buffer: 4     (should be 4)
f.length: 8     (should be 8)
f.length: 12     (should be 12)
bytes written to buffer: 4     (should be 4)
f.length: 8     (should be 8)
f.length: 12     (should be 12)
bytes written to buffer: 4     (should be 4)

assert.js:85
  throw new assert.AssertionError({
  ^
AssertionError: ArrayBuffer { byteLength: 1 } == undefined
    at Object.<anonymous> (/Users/Jeremiah/Documents/node/test/parallel/test-buffer.js:1466:8)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
Command: out/Release/node /Users/Jeremiah/Documents/node/test/parallel/test-buffer.js
[01:13|% 100|+ 1229|-   1]: Done                                               
make: *** [test] Error 1
c8099732b6bf6d9bbe320f62df71614d26b77126 is the first bad commit
commit c8099732b6bf6d9bbe320f62df71614d26b77126
Author: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Date:   Sun Aug 28 21:21:23 2016 +0530

    buffer: expose underlying buffer object always

    If the Buffer object's length is zero, or equal to the underlying
    buffer object's length, `parent` property returns `undefined`.

        > new Buffer(0).parent
        undefined
        > new Buffer(Buffer.poolSize).parent
        undefined

    This patch makes the buffer objects to consistently expose the buffer
    object via the `parent` property, always.

    Fixes: https://github.com/nodejs/node/issues/8266
    PR-URL: https://github.com/nodejs/node/pull/8311
    Reviewed-By: Trevor Norris <trev.norris@gmail.com>
    Reviewed-By: Anna Henningsen <anna@addaleax.net>
    Reviewed-By: James M Snell <jasnell@gmail.com>

:040000 040000 e81f69514f6b228dfd5b192a349f6ce1b3cc319a 807e99d3633abdf274fc5ffc92c208013daca806 M  lib
:040000 040000 da006be5fd497c7872077ef3d43878346495b7c9 52aec362d21e176cfe565bbc5b1932febfe8d6b4 M  test
bisect run success

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants