Closed Bug 912908 Opened 7 years ago Closed 3 years ago

xpcom sample doesn't work properly

Categories

(Core :: XPCOM, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED INVALID

People

(Reporter: seinlin, Assigned: seinlin)

References

Details

Attachments

(1 file, 2 obsolete files)

xpcom/sample can be built successfully, but there is an error when create instance of it.


===== test with cpp program =====
mozilla-central/objdir/dist/bin$ ./run-mozilla.sh ./nsTestSample 
ERROR: Cannot create instance of component @mozilla.org/sample;1 [80040154].
Debugging hint:
	setenv NSPR_LOG_MODULES nsComponentManager:5
	setenv NSPR_LOG_FILE xpcom.log
	./nsTestSample
	<check the contents for xpcom.log for possible cause of error>.
nsStringStats
 => mAllocCount:           2437
 => mReallocCount:          360
 => mFreeCount:             880  --  LEAKED 1557 !!!
 => mShareCount:           8084
 => mAdoptCount:             44
 => mAdoptFreeCount:         42  --  LEAKED 2 !!!



===== test with js xpcshell =====
mozilla-central/objdir/dist/bin$ ./run-mozilla.sh ./xpcshell
js> const cSample = new Components.Constructor("@mozilla.org/sample;1", "nsISample");
System JS : ERROR typein:1
                     NS_ERROR_XPC_BAD_CID: Invalid ClassID or ContractID
Assignee: nobody → kli
Attached patch bug-912908-fix.patch (obsolete) — Splinter Review
build xpcom/sample as shared library
Attachment #800079 - Flags: review?(joey)
After xpcom/sample is built as shared library, the result is as expected.

===== test with cpp program =====
mozilla-central/objdir/dist/bin$ ./run-mozilla.sh ./nsTestSample
 
Inital print: initial value
foopy 5
GetValue 8
Set value to: XPCOM defies gravity
Final print : XPCOM defies gravity
foopy 5
GetValue 8
Test passed.


===== test with js xpcshell =====
mozilla-central/objdir/dist/bin$ ./run-mozilla.sh ./xpcshell

js> const cSample = new Components.Constructor("@mozilla.org/sample;1", "nsISample");
js> var csp = new cSample();      
js> for ( var i in csp )
print(i);
QueryInterface
value
writeValue
poke
js>
Comment on attachment 800079 [details] [diff] [review]
bug-912908-fix.patch

Review of attachment 800079 [details] [diff] [review]:
-----------------------------------------------------------------

FORCE_STATIC_LIB is supported by mozbuild as a passthrough variable.

Can you move this assignment into the moz.build file:
   xpcom/sample/Makefile.in  (FORCE_STATIC_LIB = 1)
   xpcom/sample/moz.build    (FORCE_STATIC_LIB = True)

Then comment Makefile.in to note content is/should be maintained in the mozbuild file.
Attachment #800079 - Flags: review?(joey) → review-
(In reply to Joey Armstrong [:joey] from comment #4)
> Comment on attachment 800079 [details] [diff] [review]
> bug-912908-fix.patch
> 
> Review of attachment 800079 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> FORCE_STATIC_LIB is supported by mozbuild as a passthrough variable.
> 
> Can you move this assignment into the moz.build file:
>    xpcom/sample/Makefile.in  (FORCE_STATIC_LIB = 1)
>    xpcom/sample/moz.build    (FORCE_STATIC_LIB = True)
> 
> Then comment Makefile.in to note content is/should be maintained in the
> mozbuild file.

Bug 910540 added FORCE_STATIC_LIB in mozbuild as a passthrough variable but it does not appear the content has been converted yet.
Attached patch bug-912908-fix-2.patch (obsolete) — Splinter Review
FORCE_SHARED_LIB is moved to moz.build and commented in Makefile.in with a note.
Attachment #800079 - Attachment is obsolete: true
Attachment #801982 - Flags: review?(joey)
See Also: → 914270
Comment on attachment 801982 [details] [diff] [review]
bug-912908-fix-2.patch

Looks good, two small nits/edits:

Remove the commented var in Makfile.in.
Generalize the comment to cover all variables, something like:

# NOTE:
###############################################################
# Variable assignment(s) should be maintained within moz.build files whenever possible.
# Migrate existing Makefile.in content into the corresponding moz.build file, then run 'mach configure' to determine if the variable is suppported.
# If not supported / not yet converted - open a Build::Config bug requesting conversion of the variable.
#################################################################
Attachment #801982 - Flags: review?(joey) → review+
Attachment #801982 - Attachment is obsolete: true
Keywords: checkin-needed
https://hg.mozilla.org/integration/mozilla-inbound/rev/2a19516ee700

Please add your name to your hg commit information.
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/2a19516ee700
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
Could this have cause bug 915536?
hg bisect blames this bug as well on my machine...
(In reply to Tim Taubert [:ttaubert] from comment #12)
> hg bisect blames this bug as well on my machine...

And here. Backed out on the assumption that there's a lot more of us that need to run tests locally than there are that use xpcom/sample ... https://hg.mozilla.org/mozilla-central/rev/d5fc994ca2ed
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: mozilla26 → ---
Resolved base on attached patch "bug-912908-fix-3.patch".
Status: REOPENED → RESOLVED
Closed: 6 years ago6 years ago
Resolution: --- → WORKSFORME
(In reply to Kai-Zhen Li from comment #14)
> Resolved base on attached patch "bug-912908-fix-3.patch".

Uhh.... but this patch isn't currently in the tree. It needs updating so it doesn't cause bug 915536, and then should be relanded, AFAICT.
Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---
(In reply to :Gijs Kruitbosch from comment #15)
> (In reply to Kai-Zhen Li from comment #14)
> > Resolved base on attached patch "bug-912908-fix-3.patch".
> 
> Uhh.... but this patch isn't currently in the tree. It needs updating so it
> doesn't cause bug 915536, and then should be relanded, AFAICT.

Yes, this patch isn't in the tree. But I think this could be a reference to those who want to try xpcom/sample.
Flags: needinfo?(Jan.Varga)
I run "./mach mochitest-plain" with this patch but it didn't hit crash. 
But it could be the different in ".mozconfig".
This is my .mozconfig
---
# My mozilla config
ac_add_options --disable-optimize --enable-debug 
ac_add_options --enable-application=browser
ac_add_options --enable-xpctools

mk_add_options AUTOCLOBBER=1
mk_add_options MOZ_MAKE_FLAGS="-j10"
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir

export MOZ_PACKAGE_JSSHELL=1
Flags: needinfo?(Jan.Varga)
As xpcom/sample was removed in bug 1138123, resolve this bug as invalid.
Status: REOPENED → RESOLVED
Closed: 6 years ago3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.