Uh oh!
There was an error while loading. Please reload this page.
Adding the GSL as a dep + POC of its usefulness - #23821
Conversation
/CC @nodejs/platform-windows @nodejs/fs This https://ci.nodejs.org/job/node-test-commit-windows-fanned/21700/ job should uncover the bug. |
25ef826 - hooking the GSL to our PTAL |
joyeecheung
commented
Oct 31, 2018
Can you update the |
refack
commented
Oct 31, 2018
Ack. (I did it before, lost it in this revision). |
refack
commented
Oct 31, 2018
BTW: does anyone have an idea what to do with: https://github.com/nodejs/node/blob/25ef8264068cb57728fdd2f9ea5df80423cdf6b2/src/node_file.h#L208 fields->SetValue(offset + 7, gsl::narrow<NativeT>(s->st_ino));when My two ideas are either (seeking more):
If you feel like voting /CC @nodejs/fs @nodejs/platform-windows @nodejs/platform-macos |
joyeecheung
commented
Oct 31, 2018
@refack I'd suggest we leave them overflowed and recommend using the bigint version if they want to use that |
A headers only library to support following the C++ Core Guidelines. Rev: microsoft/GSL@c02ddae Refs: https://github.com/Microsoft/GSL Refs: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#S-gsl
Documented unreliability of non BigInt PTAL |
01c7de7 to
5a95506Compareaddaleax
commented
Nov 15, 2018
I’m feeling a bit uncomfortable with mixing in a valid documentation patch into a PR of this size? I think the fact that this PR has not received approvals after 24 days also says something about people’s feelings about it … you can try to get more people’s input, but I’m personally not convinced that the value added by the GSL is worth the added complexity of an extra library for us? |
We get bugs uncovered, almost for free. Real fail on smartOS: Real fail on macOS Real fail on AIX |
addaleax
commented
Nov 15, 2018
@refack Uh… so what you’re saying is that this PR introduces hard crashes into Node? I was not aware of that – I don’t think we can change the current behaviour of the (i.e. The only solution I can currently see is documenting limitations, which I am totally on board with but don’t want to mix in here) |
addaleax
left a comment
There was a problem hiding this comment.
Introducing new hard-crashes is a no-go, imo
I'm sorry if I didn't make myself clear about the crashes being an indication of the latent bug. Just like P.S. seems like it's not just |
ebc66ca to
5e69527Comparerefack
commented
Nov 16, 2018
Promoted to js tests for easier groking Line 641 in 01c7de7 smartOS: AssertionError[ERR_ASSERTION]: bigintStats.rdev: 18446744073709551615isnotequaltonumStats.rdev: 18446744073709552000atverifyStats(/home/iojs/build/workspace/node-test-commit-smartos/nodes/smartos16-64/test/parallel/test-fs-stat-ino-overflow.js:31:12)atObject.<anonymous>(/home/iojs/build/workspace/node-test-commit-smartos/nodes/smartos16-64/test/parallel/test-fs-stat-ino-overflow.js:46:3)atModule._compile(internal/modules/cjs/loader.js:722:30)atObject.Module._extensions..js(internal/modules/cjs/loader.js:733:10)atModule.load(internal/modules/cjs/loader.js:620:32)attryModuleLoad(internal/modules/cjs/loader.js:560:12)atFunction.Module._load(internal/modules/cjs/loader.js:552:3)atFunction.Module.runMain(internal/modules/cjs/loader.js:775:12)atstartup(internal/bootstrap/node.js:300:19)atbootstrapNodeJSCore(internal/bootstrap/node.js:826:3)AIX: AssertionError[ERR_ASSERTION]: bigintStats.dev: 9223372191473598466isnotequaltonumStats.dev: 9223372191473598000atverifyStats(/home/iojs/build/workspace/node-test-commit-aix/nodes/aix61-ppc64/test/parallel/test-fs-stat-ino-overflow.js:31:12)atObject.<anonymous>(/home/iojs/build/workspace/node-test-commit-aix/nodes/aix61-ppc64/test/parallel/test-fs-stat-ino-overflow.js:46:3)atModule._compile(internal/modules/cjs/loader.js:722:30)atObject.Module._extensions..js(internal/modules/cjs/loader.js:733:10)atModule.load(internal/modules/cjs/loader.js:620:32)attryModuleLoad(internal/modules/cjs/loader.js:560:12)atFunction.Module._load(internal/modules/cjs/loader.js:552:3)atFunction.Module.runMain(internal/modules/cjs/loader.js:775:12)atstartup(internal/bootstrap/node.js:300:19)atbootstrapNodeJSCore(internal/bootstrap/node.js:826:3) |
I've refactored the commits to exemplify the story:
|
Trott
commented
Nov 20, 2018
Would be great to see some explicit 👍 and/or 👎 on this one so we can get an idea what to do with it... |
rvagg
commented
Nov 22, 2018
TBH it's hard for me to get past the addition of a new thing to deps/ that doesn't remove something else (at least llhttp is aiming to remove http_parser). A question I have is—if these are such good "guidelines", why did they not make it into the language? C++, and Stroustrup himself, have a strong record of throwing shiny stuff into the language and even celebrating doing so. ("Keep developers happy by adding new stuff" is a paraphrase of something I heard Stroustrup say once). |
refack
commented
Nov 23, 2018
Most of the stuff in this library are polyfills for C++11 to give us features that got to the language only C++17 and C++20 (and they degrade when the features are available from the compiler). So I'd say think of it more like a portable compiler plugin, then a library. As I understand it the language standard moves forward very slowly end rigorously, while this library is more agile. Also The standard committee is 1000% committed to backward compatibility, while the guidelines can say "this feature is a legacy footgun, prefer the alternative new safer feature". (e.g. The big difference between this vs something like Boost is that it's very minimal (4KLoc) and 95% of the features are compile time only, with 0 run-time cost. Maybe the best analog is |
So...I don't generally disagree about this, but I'd like to remind that just because a feature is compile-time only doesn't mean it does not have an impact on the runtime performance, as there is always cache-friendliness and micro-optimizations involved. I used to not worry about the cost of templates until a coworker of mine ran into performance regressions introduced by templates because somehow the way the templates were written resulted in less cache-friendly code, even though it looked harmless and functionally equivalent...just food for thought. In the end we still need to benchmark if we are going to touch a very hot code path (although I don't think the POC here does) |
refack
commented
Nov 23, 2018
But this library was specifically designed, implemented, and coordinated with compiler writers to guarantee 0 run-time cost.
💯 agree! Which reminds me, upgrading our compilers "should" give us some "free" performance improvements, or at least it's worth evaluating (nodejs/build#1543) |
refack
commented
Jan 30, 2019
|
| if (!common.isWindows) | ||
| if (!(common.isWindows || common.isSunOS || common.isAIX)) | ||
| assert.fail('Code should fail only on Windows.'); |
There was a problem hiding this comment.
This line should be updated to include mention of the other operating systems.
Trott
commented
Jan 31, 2019
Should a different PR be opened for the content of the last two commits in this PR? (Has it already?) |
564123b deps: add the GSL
Refs: https://github.com/Microsoft/GSL
Refs: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#S-gsl
A headers only library to support following the C++ Core Guidelines. Most APIs are compile-time only (zero runtime cost) types such as:
span- which is size awareT[]string_span- same but specialized forchar[]at()- bounds safe access toT[]copy()- bounds safememcpyforspanandT[]owner- declarative ownership for naked pointersnot_null- a wrapper for pointers that does not compile if assignednullptror not initializednarrow_cast- agrapablestatic_castfor numeric types castsnarrow(has runtime cost) - a static_cast that throws on truncation.finally- an arbitrary RAII lambda wrapper[[expects]]and[[ensures]]176b82d src: example use of
gsl::narrowto uncover a bug infs::LStaton WindowsUsing
gsl::narrowuncovered a numeric truncation ofstats.inoon Windows.CI: https://ci.nodejs.org/job/node-test-pull-request/18048/
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes