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

v8 4.6.85.31 typed array bug #4191

Closed
alanpurple opened this issue Dec 8, 2015 · 12 comments
Closed

v8 4.6.85.31 typed array bug #4191

alanpurple opened this issue Dec 8, 2015 · 12 comments
Labels
invalid Issues and PRs that are invalid.

Comments

@alanpurple
Copy link

New in node 5.1.1
v8 version update is required for possible fix

https://code.google.com/p/v8/issues/detail?id=4600&can=4&colspec=ID%20Type%20Status%20Priority%20Owner%20Summary%20HW%20OS%20Area%20Stars

It was fine until node 5.0.0, I'm not sure about 5.1.0

@mscdex mscdex added the v8 engine Issues and PRs related to the V8 dependency. label Dec 8, 2015
@mscdex
Copy link
Contributor

mscdex commented Dec 8, 2015

Did you test this on most recent master branch (which has v8 4.7 now)?

@alanpurple
Copy link
Author

@mscdex you mean build node with v8 master version(which is 4.9 now)?

@mscdex
Copy link
Contributor

mscdex commented Dec 8, 2015

Sorry, I was referring to the node master branch, which currently has v8 4.7.

@alanpurple
Copy link
Author

@mscdex I don't know how to, I can build node-master version and install but I still need node-gyp(so npm) and I can't build node module using node-gyp

please let me know how to

@alanpurple
Copy link
Author

@mscdex sorry it seems same on 5.1.0 also

I need to test more version

@alanpurple
Copy link
Author

I think this is exactly the ArrayBuffer problem because sometimes it shows or right in some part

right result with C++ native program(with same source without v8 code)
1182464
110400000 110120128 109840968 104348920 103994544 103641376 103289408 102938632 102589048 102240656 101893440 101547408 101202552 100858864 100516344 100174984 99834784 99495744 99157856 98821112 98485512 98151048 97817720 97485528 97154464 96824528 96495712 96168008 95841416 95515936 95191560 94868288 94546112 94225032 93905040 93586136 93268312
110400000 109294224 108193352 102001072 100874712 99754824 98641384 97534352 96433704 95339416 94251432 93169752 92094320 91025120 89962128 88905296 87854608 86810040 85771544 84739096 83712688 82692256 81677792 80669272 79666656 78669928 77679048 76693984 75714712 74741224 73773456 72811408 71855048 70904336 69959256 69019768 68085872

output using node v8 addon with UInt32Array buffer #1
1182464
Uint32Array {
'0': 110400000,
'1': 110120128,
'2': 109840968,
'3': 104348920,
'4': 103994544,
'5': 103641376,
'6': 103289408,
'7': 102938632,
'8': 102589048,
'9': 102240656,
'10': 101893440,
'11': 101547408,
'12': 101202552,
'13': 100858864,
'14': 100516344,
'15': 100174984,
'16': 99834784,
'17': 99495744,
'18': 99157856,
'19': 98821112,
'20': 98485512,
'21': 98151048,
'22': 97817720,
'23': 97485528,
'24': 97154464,
'25': 96824528,
'26': 96495712,
'27': 96168008,
'28': 95841416,
'29': 95515936,
'30': 95191560,
'31': 94868288,
'32': 94546112,
'33': 94225032,
'34': 93905040,
'35': 93586136,
'36': 93268312 }
Uint32Array {
'0': 1328734080,
'1': 220,
'2': 18,
'3': 102001072,
'4': 0,
'5': 0,
'6': 0,
'7': 97534352,
'8': 0,
'9': 0,
'10': 0,
'11': 93169752,
'12': 2604435480,
'13': 706,
'14': 2554215440,
'15': 706,
'16': 1327732824,
'17': 220,
'18': 449071838,
'19': 84739096,
'20': 2554144016,
'21': 706,
'22': 1328734344,
'23': 220,
'24': 2554416760,
'25': 706,
'26': 2554416768,
'27': 706,
'28': 2554416776,
'29': 706,
'30': 0,
'31': 0,
'32': 0,
'33': 0,
'34': 2604440480,
'35': 706,
'36': 2604437112 }
output using node v8 addon with UInt32Array buffer #2
Debugger listening on port 5858
1182464
Uint32Array {
'0': 2622481776,
'1': 54,
'2': 18,
'3': 104348920,
'4': 0,
'5': 0,
'6': 0,
'7': 102938632,
'8': 0,
'9': 0,
'10': 0,
'11': 101547408,
'12': 981310568,
'13': 566,
'14': 949632832,
'15': 566,
'16': 2621480152,
'17': 54,
'18': 220719156,
'19': 98821112,
'20': 949557296,
'21': 566,
'22': 2622481392,
'23': 54,
'24': 949833816,
'25': 566,
'26': 949833824,
'27': 566,
'28': 949833832,
'29': 566,
'30': 0,
'31': 0,
'32': 0,
'33': 0,
'34': 981315328,
'35': 566,
'36': 981312248 }
Uint32Array {
'0': 110400000,
'1': 109294224,
'2': 108193352,
'3': 102001072,
'4': 100874712,
'5': 99754824,
'6': 98641384,
'7': 97534352,
'8': 96433704,
'9': 95339416,
'10': 94251432,
'11': 93169752,
'12': 92094320,
'13': 91025120,
'14': 89962128,
'15': 88905296,
'16': 87854608,
'17': 86810040,
'18': 85771544,
'19': 84739096,
'20': 83712688,
'21': 82692256,
'22': 81677792,
'23': 80669272,
'24': 79666656,
'25': 78669928,
'26': 77679048,
'27': 76693984,
'28': 75714712,
'29': 74741224,
'30': 73773456,
'31': 72811408,
'32': 71855048,
'33': 70904336,
'34': 69959256,
'35': 69019768,
'36': 68085872 }

and again, sometimes works fine

@alanpurple
Copy link
Author

and v8 conversion code is as below

vector<unsigned int> rp = pg.getRetailPrices();
        vector<unsigned int> up = pg.getUsedPrices();

        Local<ArrayBuffer> rpBuffer = ArrayBuffer::New(isolate, rp.data(), (numOfMonth + 1)*sizeof(unsigned int));
        Local<Uint32Array> rpArr = Uint32Array::New(rpBuffer, 0, numOfMonth + 1);
        Local<ArrayBuffer> upBuffer = ArrayBuffer::New(isolate, up.data(), (numOfMonth + 1)*sizeof(unsigned int));
        Local<Uint32Array> upArr = Uint32Array::New(upBuffer, 0, numOfMonth + 1);

        Local<Object> obj = Object::New(isolate);
        obj->Set(String::NewFromUtf8(isolate, "retailPrices"), rpArr);
        obj->Set(String::NewFromUtf8(isolate, "usedPrices"), upArr);

        args.GetReturnValue().Set(obj);

[fixed formatting - bnoordhuis]

@bnoordhuis
Copy link
Member

How sure are you the bug isn't in your code? To me it looks like the std::vector<> simply goes out of scope.

@alanpurple
Copy link
Author

Then how can the result be random only in a few elements and how can it be
sometimes right result? Im confused also
On Dec 9, 2015 1:03 AM, "Ben Noordhuis" notifications@github.com wrote:

How sure are you the bug isn't in your code? To me it looks like the
std::vector<> simply goes out of scope.


Reply to this email directly or view it on GitHub
#4191 (comment).

@alanpurple
Copy link
Author

@bnoordhuis and I provided raw reault also and it worked before

@bnoordhuis
Copy link
Member

Read up on undefined behavior; the memory backing the std::vector<> is released the moment the function returns. Closing, not a bug in node or V8.

@bnoordhuis bnoordhuis added invalid Issues and PRs that are invalid. and removed v8 engine Issues and PRs related to the V8 dependency. labels Dec 8, 2015
@alanpurple
Copy link
Author

Yep I understand thx
On Dec 9, 2015 1:16 AM, "Ben Noordhuis" notifications@github.com wrote:

Closed #4191 #4191.


Reply to this email directly or view it on GitHub
#4191 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Issues and PRs that are invalid.
Projects
None yet
Development

No branches or pull requests

3 participants