Firefox crash When using rdf:files in a composite datasource with my rdf datasource component!

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Firefox crash When using rdf:files in a composite datasource with my rdf datasource component!

benkwan-2
I write a rdf components implement the nsIRDFDataSource.the code
snippet is as following:

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

const Cc = Components.classes;
const Ci = Components.interfaces;

var gRDFService = Components.classes["@mozilla.org/rdf/rdf-service;
1"].getService(Components.interfaces.nsIRDFService);
var gRDFContainerUtils = Components.classes["@mozilla.org/rdf/
container-utils;1"].getService
(Components.interfaces.nsIRDFContainerUtils);

const NSROOT = "http://mydomain.com/rdf#";
const NSFILEROOT = "http://home.netscape.com/NC-rdf#";

//////////////////////////////////////////////////////////////////////////
const NS_Root = gRDFService.GetResource(NSROOT + "root");

function FileRDFDataSource() {};

FileRDFDataSource.prototype = {
    _xpcom_factory:
    {
        createInstance: function (aOuter, aIID)
        {
            if (aOuter != null)
                throw Components.results.NS_ERROR_NO_AGGREGATION;

            var instance = new FileRDFDataSource();
            instance._init();

            return instance.QueryInterface(aIID);
        }
    },

    _init : function()
    {
        this._rdfDataSource = Components.classes["@mozilla.org/rdf/
datasource;1?name=xml-datasource"]
                                                .createInstance
(Components.interfaces.nsIRDFDataSource);

        //临时rdfsource的uri
        var tmpRDFUri = NSROOT + _generateUUID();
        var ios=Components.classes["@mozilla.org/network/io-service;
1"]
                                        .getService
(Components.interfaces.nsIIOService);

        // I know little about this variable, about what and how it
using for.
        baseUri=ios.newURI(tmpRDFUri,null,null);

        var parser=Components.classes["@mozilla.org/rdf/xml-parser;1"]
                                                 .createInstance
(Components.interfaces.nsIRDFXMLParser);
        var sRdfContent = '<?xml version="1.0"?><RDF:RDF xmlns:NS1="'
+ NSROOT +'" ' +
                                            ' xmlns:NC="http://
home.netscape.com/NC-rdf#"' +
                                            ' xmlns:RDF="http://
www.w3.org/1999/02/22-rdf-syntax-ns#">' +
                                            ' <RDF:Seq RDF:about="' +
NSROOT + 'root"> '+
                                            ' </RDF:Seq>';

        //初始化数据源
        parser.parseString(this._rdfDataSource,baseUri,sRdfContent);

        var rootContainer = gRDFContainerUtils.MakeSeq
(this._rdfDataSource, NS_Root);

        ////////////////////////////////////////////////////////////////////////////
        var CRes = gRDFService.GetResource("file:///C|/");
        rootContainer.AppendElement(CRes);

        var DRes = gRDFService.GetResource("file:///D|/");
        rootContainer.AppendElement(DRes);
    }

    //nsIRDFDataSource interfaces

    get URI()
    {
        return "FileRDFDataSource";
    },

    AddObserver: function(aObserver)
    {
        this._rdfDataSource.AddObserver(aObserver);
    },

    ......
    Unassert: function(aSource,aProperty,aTarget)
    {
        this._rdfDataSource.Unassert(aSource,aProperty,aTarget);
    }
};

And then i use in the tree datasources properties like it:

<tree id="filelisttree_ben1" flex="1" datasources="rdf:files
rdf:cefilerdfdatasource" ref="http://mydomain.com/rdf#root">

when i open this xul by chrome,it diplay the C disk And D disk ,but
when i toggle the node of C disk,the firefox crash! And toggling the
node of C disk is OK.
i don't know why it crash!!

and i make another test:
i save the rdf as a file : this._rdfDataSource.QueryInterface
(Ci.nsIRDFRemoteDataSource).FlushTo("file:\\\\\\D:\\filerdf.rdf");

and the xul code like these :
<tree id="filelisttree_ben1" flex="1" datasources="rdf:files
chrome://test/content/filerdf.rdf" ref="http://mydomain.com/
rdf#root">

everything is OK!

Is there something wrong i write the XPCOM component? I can't think it
out! Can someone tell me why?
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: Firefox crash When using rdf:files in a composite datasource with my rdf datasource component!

Neil-4
BenKwan wrote:

><tree id="filelisttree_ben1" flex="1" datasources="rdf:files rdf:cefilerdfdatasource" ref="http://mydomain.com/rdf#root">
>
>when i open this xul by chrome,it diplay the C disk And D disk ,but when i toggle the node of C disk,the firefox crash! And toggling the node of C disk is OK.
>  
>
Out of interest, does this crash:

<tree id="filelisttree_ben1" flex="1" datasources="rdf:files" ref="NC:FilesRoot">

I know RDF uses unsafe pointers in some cases so this could possibly be
your problem - there was a similar issue with the extension manager data
source. Unfortunately the crashes this produces are hard to diagnose.

--
Warning: May contain traces of nuts.
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: Firefox crash When using rdf:files in a composite datasource with my rdf datasource component!

benkwan-2
On Jun 22, 7:01 pm, Neil <[hidden email]> wrote:

> BenKwan wrote:
> ><tree id="filelisttree_ben1" flex="1" datasources="rdf:files rdf:cefilerdfdatasource" ref="http://mydomain.com/rdf#root">
>
> >when i open this xul by chrome,it diplay the C disk And D disk ,but when i toggle the node of C disk,the firefox crash! And toggling the node of C disk is OK.
>
> Out of interest, does this crash:
>
> <tree id="filelisttree_ben1" flex="1" datasources="rdf:files" ref="NC:FilesRoot">
>
> I know RDF uses unsafe pointers in some cases so this could possibly be
> your problem - there was a similar issue with the extension manager data
> source. Unfortunately the crashes this produces are hard to diagnose.
>
> --
> Warning: May contain traces of nuts.

in order to test,i have 3 tree:

<tree id="filelisttree" flex="1" datasources="rdf:files"
ref="NC:FilesRoot">

<tree id="filelisttree_ben" flex="1" datasources="rdf:files
chrome://test/content/filerdf.rdf" ref="http://
addressbook.desktopx.org/rdf#root">

<tree id="filelisttree_ben1" flex="1" datasources="rdf:files
rdf:cefilerdfdatasource" ref="http://addressbook.desktopx.org/
rdf#root">

the first and the second tree perform good! And the last one crashs.
In the second tree the filerdf.rdf is generated by invoke the FlushTo
method of the datasources "rdf:cefilerdfdatasource". I am puzzled by
why the third one crashs. And according to my test, its crash is
different betweent WinXP and WinVista. In Vista,only and once when i
toggle any file node in C disk of the tree, the FF  crash. But in
WinXp ,it crash ruleless.

and i am building a debug version ff to test and find out the problem!
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: Firefox crash When using rdf:files in a composite datasource with my rdf datasource component!

benkwan-2
I debuged in the debug version xulrunner and find that it crashs in
the method "IsEmpty" of RDFContainerUtilsImpl in the mozilla\rdf\base
\src\nsRDFContainerUtils.cpp. It crashs because of using null ptr at
this code snippet:
/////////////////////////////////////////////////////
NS_IMETHODIMP
RDFContainerUtilsImpl::IsEmpty(nsIRDFDataSource* aDataSource,
nsIRDFResource* aResource, PRBool* _retval)
{
    if (! aDataSource)
        return NS_ERROR_NULL_POINTER;

    nsresult rv;

    // By default, say that we're an empty container. Even if we're
not
    // really even a container.
    *_retval = PR_TRUE;

    nsCOMPtr<nsIRDFNode> nextValNode;
    rv = aDataSource->GetTarget(aResource, kRDF_nextVal, PR_TRUE,
getter_AddRefs(nextValNode));  //the problem is caused here!
    if (NS_FAILED(rv)) return rv;

        //NS_ENSURE_TRUE(nextValNode,NS_ERROR_NULL_POINTER); //the code i
Add,uncomment it and it goes good!

    if (rv == NS_RDF_NO_VALUE)
        return NS_OK;

    nsCOMPtr<nsIRDFLiteral> nextValLiteral;
    rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral),
getter_AddRefs(nextValLiteral)); //nextValNode is null,it crash!
    if (NS_FAILED(rv)) return rv;

    if (nextValLiteral.get() != kOne)
        *_retval = PR_FALSE;

    return NS_OK;
}
/////////////////////////////////////////////////////

when my tree is:
<tree id="filelisttree" flex="1" datasources="rdf:files"
ref="NC:FilesRoot">

OR

<tree id="filelisttree_ben" flex="1" datasources="rdf:files
chrome://test/content/filerdf.rdf" ref="http://
addressbook.desktopx.org/rdfroot">

the nextValNode got from "GetTarget" is null and the return value rv
is non-zero,so it goes good;but when my tree is :
<tree id="filelisttree_ben1" flex="1" datasources="rdf:files
rdf:cefilerdfdatasource" ref="http://addressbook.desktopx.org/
rdf#root">

the nextValNode is also null,but the return value rv is 0,so when go
to this sentence:

rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral),
getter_AddRefs(nextValLiteral));

it crash!

when i add "NS_ENSURE_TRUE(nextValNode,NS_ERROR_NULL_POINTER);" in the
method,everything is OK.Why the retrun value is so different?Is it a
bug?

My test is here:
http://sites.google.com/site/freebendy/Home/test.rar?attredirects=0

PS:
  placed the folder "test" and test.manifest in the chrome
directory,dxfilerdf.js file in components directory. Delete the
comreg.dat and xpti,dat in the profile directory!



_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: Firefox crash When using rdf:files in a composite datasource with my rdf datasource component!

benkwan-2
In reply to this post by benkwan-2
I debuged in the debug version xulrunner and find that it crashs in
the method "IsEmpty" of RDFContainerUtilsImpl in the mozilla\rdf\base
\src\nsRDFContainerUtils.cpp. It crashs because of using null ptr at
this code snippet:
/////////////////////////////////////////////////////
NS_IMETHODIMP
RDFContainerUtilsImpl::IsEmpty(nsIRDFDataSource* aDataSource,
nsIRDFResource* aResource, PRBool* _retval)
{
    if (! aDataSource)
        return NS_ERROR_NULL_POINTER;

    nsresult rv;

    // By default, say that we're an empty container. Even if we're
not
    // really even a container.
    *_retval = PR_TRUE;

    nsCOMPtr<nsIRDFNode> nextValNode;
    rv = aDataSource->GetTarget(aResource, kRDF_nextVal, PR_TRUE,
getter_AddRefs(nextValNode));  //the problem is caused here!
    if (NS_FAILED(rv)) return rv;

        //NS_ENSURE_TRUE(nextValNode,NS_ERROR_NULL_POINTER); //the code i
Add,uncomment it and it goes good!

    if (rv == NS_RDF_NO_VALUE)
        return NS_OK;

    nsCOMPtr<nsIRDFLiteral> nextValLiteral;
    rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral),
getter_AddRefs(nextValLiteral)); //nextValNode is null,it crash!
    if (NS_FAILED(rv)) return rv;

    if (nextValLiteral.get() != kOne)
        *_retval = PR_FALSE;

    return NS_OK;
}
/////////////////////////////////////////////////////

when my tree is:
<tree id="filelisttree" flex="1" datasources="rdf:files"
ref="NC:FilesRoot">

OR

<tree id="filelisttree_ben" flex="1" datasources="rdf:files
chrome://test/content/filerdf.rdf" ref="http://
addressbook.desktopx.org/rdfroot">

the nextValNode got from "GetTarget" is null and the return value rv
is non-zero,so it goes good;but when my tree is :
<tree id="filelisttree_ben1" flex="1" datasources="rdf:files
rdf:cefilerdfdatasource" ref="http://addressbook.desktopx.org/
rdf#root">

the nextValNode is also null,but the return value rv is 0,so when go
to this sentence:

rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral),
getter_AddRefs(nextValLiteral));

it crash!

when i add "NS_ENSURE_TRUE(nextValNode,NS_ERROR_NULL_POINTER);" in the
method,everything is OK.Why the retrun value is so different?Is it a
bug?

My test is here:
http://sites.google.com/site/freebendy/Home/test.rar?attredirects=0

PS:
  placed the folder "test" and test.manifest in the chrome
directory,dxfilerdf.js file in components directory. Delete the
comreg.dat and xpti,dat in the profile directory!



_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: Firefox crash When using rdf:files in a composite datasource with my rdf datasource component!

benkwan-2
In reply to this post by benkwan-2
I debuged in the debug version xulrunner and find that it crashs in
the method "IsEmpty" of RDFContainerUtilsImpl in the mozilla\rdf\base
\src\nsRDFContainerUtils.cpp. It crashs because of using null ptr at
this code snippet:
/////////////////////////////////////////////////////
NS_IMETHODIMP
RDFContainerUtilsImpl::IsEmpty(nsIRDFDataSource* aDataSource,
nsIRDFResource* aResource, PRBool* _retval)
{
    if (! aDataSource)
        return NS_ERROR_NULL_POINTER;

    nsresult rv;

    // By default, say that we're an empty container. Even if we're
not
    // really even a container.
    *_retval = PR_TRUE;

    nsCOMPtr<nsIRDFNode> nextValNode;
    rv = aDataSource->GetTarget(aResource, kRDF_nextVal, PR_TRUE,
getter_AddRefs(nextValNode));  //the problem is caused here!
    if (NS_FAILED(rv)) return rv;

        //NS_ENSURE_TRUE(nextValNode,NS_ERROR_NULL_POINTER); //the code i
Add,uncomment it and it goes good!

    if (rv == NS_RDF_NO_VALUE)
        return NS_OK;

    nsCOMPtr<nsIRDFLiteral> nextValLiteral;
    rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral),
getter_AddRefs(nextValLiteral)); //nextValNode is null,it crash!
    if (NS_FAILED(rv)) return rv;

    if (nextValLiteral.get() != kOne)
        *_retval = PR_FALSE;

    return NS_OK;
}
/////////////////////////////////////////////////////

when my tree is:
<tree id="filelisttree" flex="1" datasources="rdf:files"
ref="NC:FilesRoot">

OR

<tree id="filelisttree_ben" flex="1" datasources="rdf:files
chrome://test/content/filerdf.rdf" ref="http://
addressbook.desktopx.org/rdfroot">

the nextValNode got from "GetTarget" is null and the return value rv
is non-zero,so it goes good;but when my tree is :
<tree id="filelisttree_ben1" flex="1" datasources="rdf:files
rdf:cefilerdfdatasource" ref="http://addressbook.desktopx.org/
rdf#root">

the nextValNode is also null,but the return value rv is 0,so when go
to this sentence:

rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral),
getter_AddRefs(nextValLiteral));

it crash!

when i add "NS_ENSURE_TRUE(nextValNode,NS_ERROR_NULL_POINTER);" in the
method,everything is OK.Why the retrun value is so different?Is it a
bug?

My test is here:
http://sites.google.com/site/freebendy/Home/test.rar?attredirects=0

PS:
  placed the folder "test" and test.manifest in the chrome
directory,dxfilerdf.js file in components directory. Delete the
comreg.dat and xpti,dat in the profile directory!



_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: Firefox crash When using rdf:files in a composite datasource with my rdf datasource component!

benkwan-2
In reply to this post by benkwan-2
i find another way to fix this problem:

    GetTarget: function(aSource,aProperty,aTruthValue)
    {
        var retVal = this._rdfDataSource.GetTarget
(aSource,aProperty,aTruthValue);
        if(!retVal)
        {
            throw Components.results.NS_ERROR_FAILURE;
        }
        return retVal;
    },

Is it mean that the RDFContainerUtils leave the work of disposing
error to the implementation of nsIRDFDataSource?
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: Firefox crash When using rdf:files in a composite datasource with my rdf datasource component!

Neil-4
BenKwan wrote:

>i find another way to fix this problem:
>
>    GetTarget: function(aSource,aProperty,aTruthValue)
>    {
>        var retVal = this._rdfDataSource.GetTarget
>(aSource,aProperty,aTruthValue);
>        if(!retVal)
>        {
>            throw Components.results.NS_ERROR_FAILURE;
>        }
>        return retVal;
>    },
>
>Is it mean that the RDFContainerUtils leave the work of disposing error to the implementation of nsIRDFDataSource?
>  
>
What's normally supposed to happen is that the GetTarget function
returns NS_RDF_NO_VALUE in this case. Unfortunately JS doesn't support
this value, instead it can only return null. As you have found out, the
best you can do is to throw NS_ERROR_FAILURE.

--
Warning: May contain traces of nuts.
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf
Reply | Threaded
Open this post in threaded view
|

Re: Firefox crash When using rdf:files in a composite datasource with my rdf datasource component!

benkwan-2
On Jun 23, 5:02 pm, Neil <[hidden email]> wrote:

> BenKwan wrote:
> >i find another way to fix this problem:
>
> >    GetTarget: function(aSource,aProperty,aTruthValue)
> >    {
> >        var retVal = this._rdfDataSource.GetTarget
> >(aSource,aProperty,aTruthValue);
> >        if(!retVal)
> >        {
> >            throw Components.results.NS_ERROR_FAILURE;
> >        }
> >        return retVal;
> >    },
>
> >Is it mean that the RDFContainerUtils leave the work of disposing error to the implementation of nsIRDFDataSource?
>
> What's normally supposed to happen is that the GetTarget function
> returns NS_RDF_NO_VALUE in this case. Unfortunately JS doesn't support
> this value, instead it can only return null. As you have found out, the
> best you can do is to throw NS_ERROR_FAILURE.
>
> --
> Warning: May contain traces of nuts.

right,i read the code just now! So unfortunately according to the
RDFDatasource Components implemented by C++ or JS,.it performs
differnt! :<  And thx a lot for your help!:)
_______________________________________________
dev-tech-rdf mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-rdf