The default bug view has changed. See this FAQ.

js-ctypes doesn't handle void callbacks

RESOLVED FIXED in mozilla10

Status

()

Core
js-ctypes
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: bholley, Assigned: bholley)

Tracking

unspecified
mozilla10
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 3 obsolete attachments)

We check the void case here: http://hg.mozilla.org/mozilla-central/file/906413a7ae6b/js/src/ctypes/CTypes.cpp#l5365

After that though, we still call ImplicitConvert unconditionally: http://hg.mozilla.org/mozilla-central/file/906413a7ae6b/js/src/ctypes/CTypes.cpp#l5414

The first thing we do within ImplicitConvert is assert IsSizeDefined() on the target type. This is false for a void return value.

Patch and test coverage coming right up.
Assignee: nobody → bobbyholley+bmo
Depends on: 682180
Created attachment 556211 [details] [diff] [review]
Don't try to ImplicitConvert a void return value. v1

Attached a patch. Flagging dwitte for review.
Attachment #556211 - Flags: review?(dwitte)
Created attachment 556212 [details] [diff] [review]
Tests. v1

Attached tests. Flagging jorendorff for review.
Attachment #556212 - Flags: review?(jorendorff)
Blocks: 599791
Comment on attachment 556211 [details] [diff] [review]
Don't try to ImplicitConvert a void return value. v1

Stealing review. This is correct (but should not land without the tests of course).
Attachment #556211 - Flags: review?(dwitte) → review+
Comment on attachment 556212 [details] [diff] [review]
Tests. v1

I guess there is no such thing as a bad test, but note that this can be tested without touching the C++ library. The simplest test is like this:

  var fnptr_t = ctypes.FunctionType(ctypes.default_abi, ctypes.void_t, []).ptr;
  fnptr_t(function () {})();  // don't crash

It crashes without the patch. I can't overstate how nice it is to have small tests--so please add a test with just this in it, if you can do that.

Otherwise r=me. Thanks.
Attachment #556212 - Flags: review?(jorendorff) → review+
Created attachment 556617 [details] [diff] [review]
Tests. v2

> The simplest test is like this:

Ah, good idea! Attaching an updated patch and carrying over review.
Attachment #556212 - Attachment is obsolete: true
Attachment #556617 - Flags: review+
Created attachment 556619 [details] [diff] [review]
Tests. v2

Whoops, small bug in my push-to-bugzilla script. Sorry for the bugspam.
Attachment #556617 - Attachment is obsolete: true
Attachment #556619 - Flags: review+
Created attachment 556622 [details] [diff] [review]
Tests. v2

Still not quite right. This should do it.
Attachment #556619 - Attachment is obsolete: true
Attachment #556622 - Flags: review+
Duplicate of this bug: 666929
Pushed to mozilla-inbound: http://hg.mozilla.org/integration/mozilla-inbound/rev/f13920d33454

This had a green try run, modulo known oranges: https://tbpl.mozilla.org/?tree=Try&usebuildbot=1&rev=e71f6e3a3771
Status: NEW → ASSIGNED
Flags: in-testsuite+
Target Milestone: --- → mozilla10
https://hg.mozilla.org/mozilla-central/rev/c5ed26ad5709
https://hg.mozilla.org/mozilla-central/rev/f13920d33454
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.