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

Bufferobject field write sign handling issues on an exotic old ARM platform #336

Open
svaarala opened this Issue Sep 11, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@svaarala
Copy link
Owner

svaarala commented Sep 11, 2015

This issue is limited to an exotic older ARM platform. Due to float-integer cast bugs in the platform, casting a double to an integer doesn't always work correctly. Here's an example what happens with Node.js Buffer binding:

# duk
((o) Duktape [no readline] 1.2.99 (v1.2.0-591-g530ca64-dirty)
duk> Duktape.env
= lm pf pn p2 a4 arm linux gcc
duk> b = new Buffer('ABCDEFGH')
= ABCDEFGH
duk> Duktape.enc('jx', Duktape.Buffer(b))
= |4142434445464748|
duk> b.writeUInt32BE(0xdeadbeef, 3)
= 7
duk> Duktape.enc('jx', Duktape.Buffer(b))
= |4142437fffffff48|
duk> b.writeUInt32BE(0x3eadbeef, 3)
= 7
duk> Duktape.enc('jx', Duktape.Buffer(b))
= |4142433eadbeef48|

So, 0xdeadbeef gets written as 0x7fffffff, but 0x3eadbeef is written correctly.

This is obviously a platform bug (and a known issue), but I'll try to figure out if this can be accommodated somehow in duk_config.h without a big impact on other platforms.

Cast issues seem to be surprisingly common in more exotic platforms, so perhaps using a macro to cast from double to various integer types would be appropriate. The cast can often be fixed with inline asm or a C workaround (which is what I've done on this platform previously).

@svaarala svaarala added this to the v1.4.0 milestone Sep 11, 2015

@svaarala svaarala referenced this issue Sep 11, 2015

Closed

Cleanups for 1.3.0 release #203

33 of 33 tasks complete

svaarala added a commit that referenced this issue Sep 11, 2015

svaarala added a commit that referenced this issue Sep 11, 2015

Add testcase for GH-336
This is not actually a Duktape bug, but rather a bug in the platform double
to integer coercion which impacts Duktape.

@svaarala svaarala modified the milestones: v1.5.0, v1.4.0 Nov 24, 2015

@svaarala svaarala removed this from the v1.5.0 milestone Apr 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment