TooTallNate / ref

Turn Buffer instances into "pointers"
http://tootallnate.github.com/ref
453 stars 141 forks source link

Node 5.0: ref.NULL is broken #45

Closed ghalle closed 8 years ago

ghalle commented 8 years ago

I was trying to use node-ffi and something was not working, I tracked it down to ref.NULL I ran the tests and all the tests related to ref.NULL are failing.

I ran the tests on Windows 7 64 bit.

These are the failing tests:

  1) address should return 0 for the NULL pointer:

      AssertionError: 0 === 3376672
      + expected - actual

      -0
      +3376672

      at Context.<anonymous> (\ref\test\address.js:10:12)

  2) int64 should throw an Error when reading an int64_t from the NULL pointer:
     AssertionError: Missing expected exception..
      at Function._throws (assert.js:306:5)
      at Function.assert.throws (assert.js:323:11)
      at Context.<anonymous> (\ref\test\int64.js:70:12)

  3) int64 should throw an Error when reading a uint64_t from the NULL pointer:
     AssertionError: Missing expected exception..
      at Function._throws (assert.js:306:5)
      at Function.assert.throws (assert.js:323:11)
      at Context.<anonymous> (\ref\test\int64.js:76:12)

  4) isNull should return "true" for the NULL pointer:

      AssertionError: true === false
      + expected - actual

      -true
      +false

      at Context.<anonymous> (\ref\test\isNull.js:8:12)

  5) Object should throw an Error when reading an Object from the NULL pointer:
     AssertionError: Missing expected exception..
      at Function._throws (assert.js:306:5)
      at Function.assert.throws (assert.js:323:11)
      at Context.<anonymous> (\ref\test\object.js:50:12)

  6) pointer should throw an Error when reading from the NULL pointer:
     AssertionError: Missing expected exception..
      at Function._throws (assert.js:306:5)
      at Function.assert.throws (assert.js:323:11)
      at Context.<anonymous> (\ref\test\pointer.js:49:12)

  7) pointer should return a 0-length Buffer when reading a NULL pointer:

      AssertionError: 100 === 0
      + expected - actual

      -100
      +0

      at Context.<anonymous> (\ref\test\pointer.js:58:12)

  8) C string readCString() should throw an Error when reading from the NULL pointer:
     AssertionError: Missing expected exception..
      at Function._throws (assert.js:306:5)
      at Function.assert.throws (assert.js:323:11)
      at Context.<anonymous> (\ref\test\string.js:20:14)

  9) C string allocCString() should return the NULL pointer for `null` values:

      AssertionError: false == true
      + expected - actual

      -false
      +true

      at Context.<anonymous> (\ref\test\string.js:50:7)

  10) C string allocCString() should return the NULL pointer for `undefined` values:

      AssertionError: false == true
      + expected - actual

      -false
      +true

      at Context.<anonymous> (\ref\test\string.js:56:7)

  11) C string allocCString() should return the NULL pointer for a NULL pointer Buffer:

      AssertionError: expected a "string" as the third argument
      + expected - actual

      -string
      +object

      at Object.writeCString (\ref\lib\ref.js:564:10)
      at Object.allocCString (\ref\lib\ref.js:544:11)
      at Context.<anonymous> (\ref\test\string.js:61:21)

  12) C string CString should return JS `null` when given a pointer pointing to NULL:
     AssertionError: null === '#'
      at Context.<anonymous> (\ref\test\string.js:73:14)
TooTallNate commented 8 years ago

Thanks for the report. Travis agrees. Reporting upstream.

TooTallNate commented 8 years ago

Looks like nodejs/node@d8011d1683fe0d977de2bea1147f5213d4490c5a is the breaking commit…

TooTallNate commented 8 years ago

Fixed in nodejs/node@827ee498e332e316421f565c5f763f347f81274c.

See https://github.com/nodejs/node/issues/3781 for posterity.