Closed Bug 682504 Opened 9 years ago Closed 8 years ago

js-ctypes doesn't handle void callbacks

Categories

(Core :: js-ctypes, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla10

People

(Reporter: bholley, Assigned: bholley)

References

Details

Attachments

(2 files, 3 obsolete files)

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
Attached a patch. Flagging dwitte for review.
Attachment #556211 - Flags: review?(dwitte)
Attached patch Tests. v1 (obsolete) — Splinter Review
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+
Attached patch Tests. v2 (obsolete) — Splinter Review
> 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+
Attached patch Tests. v2 (obsolete) — Splinter Review
Whoops, small bug in my push-to-bugzilla script. Sorry for the bugspam.
Attachment #556617 - Attachment is obsolete: true
Attachment #556619 - Flags: review+
Attached patch Tests. v2Splinter Review
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
You need to log in before you can comment on or make changes to this bug.