Last Comment Bug 682504 - js-ctypes doesn't handle void callbacks
: js-ctypes doesn't handle void callbacks
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: js-ctypes (show other bugs)
: unspecified
: All All
: -- normal (vote)
: mozilla10
Assigned To: Bobby Holley (:bholley) (busy with Stylo)
:
Mentors:
: 666929 (view as bug list)
Depends on: 682180
Blocks: 599791
  Show dependency treegraph
 
Reported: 2011-08-26 20:59 PDT by Bobby Holley (:bholley) (busy with Stylo)
Modified: 2011-10-09 07:25 PDT (History)
3 users (show)
bobbyholley: in‑testsuite+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Don't try to ImplicitConvert a void return value. v1 (1.13 KB, patch)
2011-08-26 21:05 PDT, Bobby Holley (:bholley) (busy with Stylo)
jorendorff: review+
Details | Diff | Splinter Review
Tests. v1 (4.24 KB, patch)
2011-08-26 21:08 PDT, Bobby Holley (:bholley) (busy with Stylo)
jorendorff: review+
Details | Diff | Splinter Review
Tests. v2 (1.35 KB, patch)
2011-08-29 11:10 PDT, Bobby Holley (:bholley) (busy with Stylo)
bobbyholley: review+
Details | Diff | Splinter Review
Tests. v2 (1.35 KB, patch)
2011-08-29 11:15 PDT, Bobby Holley (:bholley) (busy with Stylo)
bobbyholley: review+
Details | Diff | Splinter Review
Tests. v2 (1.35 KB, patch)
2011-08-29 11:23 PDT, Bobby Holley (:bholley) (busy with Stylo)
bobbyholley: review+
Details | Diff | Splinter Review

Description Bobby Holley (:bholley) (busy with Stylo) 2011-08-26 20:59:28 PDT
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.
Comment 1 Bobby Holley (:bholley) (busy with Stylo) 2011-08-26 21:05:00 PDT
Created attachment 556211 [details] [diff] [review]
Don't try to ImplicitConvert a void return value. v1

Attached a patch. Flagging dwitte for review.
Comment 2 Bobby Holley (:bholley) (busy with Stylo) 2011-08-26 21:08:14 PDT
Created attachment 556212 [details] [diff] [review]
Tests. v1

Attached tests. Flagging jorendorff for review.
Comment 3 Jason Orendorff [:jorendorff] 2011-08-29 08:36:08 PDT
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).
Comment 4 Jason Orendorff [:jorendorff] 2011-08-29 08:49:56 PDT
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.
Comment 5 Bobby Holley (:bholley) (busy with Stylo) 2011-08-29 11:10:10 PDT
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.
Comment 6 Bobby Holley (:bholley) (busy with Stylo) 2011-08-29 11:15:47 PDT
Created attachment 556619 [details] [diff] [review]
Tests. v2

Whoops, small bug in my push-to-bugzilla script. Sorry for the bugspam.
Comment 7 Bobby Holley (:bholley) (busy with Stylo) 2011-08-29 11:23:29 PDT
Created attachment 556622 [details] [diff] [review]
Tests. v2

Still not quite right. This should do it.
Comment 8 Bobby Holley (:bholley) (busy with Stylo) 2011-08-29 12:26:59 PDT
*** Bug 666929 has been marked as a duplicate of this bug. ***
Comment 9 Bobby Holley (:bholley) (busy with Stylo) 2011-10-07 10:55:50 PDT
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

Note You need to log in before you can comment on or make changes to this bug.