Xojo Conferences
XDCMay2019MiamiUSA

Strange crashes with registering class extension (Real Studio Plugins Mailinglist archive)

Back to the thread list
Previous thread: using timer as event filter
Next thread: Teleo Modules


macosx and unix paths   -   GOLD
  Strange crashes with registering class extension   -   Christian Schmitz
   Re: Strange crashes with registering class extension   -   Joseph J. Strout
    Re: Strange crashes with registering class extension   -   Christian Schmitz
     Re: Strange crashes with registering class extension   -   Joseph J. Strout
      Re: Strange crashes with registering class extension   -   Christian Schmitz
     Re: Strange crashes with registering class extension   -   James Milne
      Re: Strange crashes with registering class extension   -   Alfred Van Hoek
     Re: Strange crashes with registering class extension   -   Norman Palardy
      Re: Strange crashes with registering class extension   -   Christian Schmitz
       Re: Strange crashes with registering class extension   -   Norman Palardy
       Re: Strange crashes with registering class extension   -   Joseph J. Strout

Strange crashes with registering class extension
Date: 25.06.04 16:50 (Fri, 25 Jun 2004 17:50:00 +0200)
From: Christian Schmitz
Hi,

{ (REALproc) CreatePDFDocument2, REALnoImplementation,
"NewCGPDFDocumentWithInfoMBS(MediaBox as "CGRectMBS", info as object) as
"CGContextMBS},

works on the folderitem class, but

{ (REALproc) CreatePDFDocument2, REALnoImplementation,
"NewCGPDFDocumentWithInfoMBS(MediaBox as "CGRectMBS", info as
"CFDictionary") as "CGContextMBS},

does not.

Strange.
RB 4.5 crashes on class registration, but only in a compiled app, not in
the IDE. RB 5.5 shows a memory overwritten (over end of block)

Any idea?
Over hundred other class extensions work.

Mfg
Christian

Re: Strange crashes with registering class extension
Date: 25.06.04 17:01 (Fri, 25 Jun 2004 11:01:01 -0500)
From: Joseph J. Strout
At 5:50 PM +0200 6/25/04, Christian Schmitz wrote:

> { (REALproc) CreatePDFDocument2, REALnoImplementation,
>"NewCGPDFDocumentWithInfoMBS(MediaBox as "CGRectMBS", info as object) as
>"CGContextMBS},
>
>works on the folderitem class, but
>
> { (REALproc) CreatePDFDocument2, REALnoImplementation,
>"NewCGPDFDocumentWithInfoMBS(MediaBox as "CGRectMBS", info as
>"CFDictionary") as "CGContextMBS},
>
>does not.

This can't be copied-and-pasted code... it doesn't even look like
valid C code to me. What's with the extra quotes around some of your
types?

Re: Strange crashes with registering class extension
Date: 25.06.04 18:05 (Fri, 25 Jun 2004 19:05:32 +0200)
From: Christian Schmitz
Joseph J. Strout <<email address removed>> wrote:

> This can't be copied-and-pasted code... it doesn't even look like
> valid C code to me. What's with the extra quotes around some of your
> types?

constants.
All the class names are constants so I don't make type errors.

Mfg
Christian

Re: Strange crashes with registering class extension
Date: 25.06.04 19:27 (Fri, 25 Jun 2004 13:27:38 -0500)
From: Joseph J. Strout
At 7:05 PM +0200 6/25/04, Christian Schmitz wrote:

> > This can't be copied-and-pasted code... it doesn't even look like
>> valid C code to me. What's with the extra quotes around some of your
>> types?
>
>constants.
>All the class names are constants so I don't make type errors.

Ah. Sneaky.

In that case, the only difference I can see between the one that
works and the one that doesn't, is that the latter has a parameter of
type CFDictionary. Could it be that CFDictionary has not yet been
registered at the time this class extension is being registered?

Best,
- Joe

Re: Strange crashes with registering class extension
Date: 26.06.04 00:51 (Sat, 26 Jun 2004 01:51:20 +0200)
From: Christian Schmitz
Joseph J. Strout <<email address removed>> wrote:

> In that case, the only difference I can see between the one that
> works and the one that doesn't, is that the latter has a parameter of
> type CFDictionary. Could it be that CFDictionary has not yet been
> registered at the time this class extension is being registered?

CF classes are defined in another plugin which is in the CW linkorder to
be loaded before this plugin.

But I must really say: the order of plugins should not be important.

Mfg
Christian

Re: Strange crashes with registering class extension
Date: 26.06.04 00:45 (Sat, 26 Jun 2004 00:45:39 +0100)
From: James Milne

On 25 Jun, 2004, at 19:27, Joseph J. Strout wrote:

> At 7:05 PM +0200 6/25/04, Christian Schmitz wrote:
>
>> > This can't be copied-and-pasted code... it doesn't even look like
>>> valid C code to me. What's with the extra quotes around some of
>>> your
>>> types?
>>
>> constants.
>> All the class names are constants so I don't make type errors.
>
> Ah. Sneaky.
>
> In that case, the only difference I can see between the one that works
> and the one that doesn't, is that the latter has a parameter of type
> CFDictionary. Could it be that CFDictionary has not yet been
> registered at the time this class extension is being registered?

No- I've had precisely the same problem with plugins before, and I'm
buggered if I can figure out what it is.

I was defining class names in this form:

const char* szClassName = "SomeClass";

If you pass szClassName in as the name of your class to an RB struture,
RB will crash when it loads the plugin. However, if you define your
value using, for example, a #define, it works ok; ie:

#define szClassName "SomeClass"

I can only presume there must be something strange about such
string constants, whether it be that they require static
initialisation to fix up their pointer or something. But they
don't work when you pass them into RB definition structures.

Re: Strange crashes with registering class extension
Date: 26.06.04 03:14 (Fri, 25 Jun 2004 22:14:24 -0400)
From: Alfred Van Hoek
on 6/25/04 7:45 PM, James Milne at <email address removed> wrote:

>> In that case, the only difference I can see between the one that works
>> and the one that doesn't, is that the latter has a parameter of type
>> CFDictionary. Could it be that CFDictionary has not yet been
>> registered at the time this class extension is being registered?
>
> No- I've had precisely the same problem with plugins before, and I'm
> buggered if I can figure out what it is.
>
> I was defining class names in this form:
>
> const char* szClassName = "SomeClass";
>
> If you pass szClassName in as the name of your class to an RB struture,
> RB will crash when it loads the plugin. However, if you define your
> value using, for example, a #define, it works ok; ie:
>
> #define szClassName "SomeClass"

Although this may be true it can't be a reason Christian observes, since he
uses more than one class constants. In one case it works, in the other case
it does not, and therefore the only possibility, short of getting more info,
is that CFDictionary does not exists yet. Replacing it to an object, which
is weak binding, cures it..

This to avoid a repeated discussion on static initializers, which is not a
good thing when plugins are being loaded...

Alfred

_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Strange crashes with registering class extension
Date: 26.06.04 00:50 (Fri, 25 Jun 2004 17:50:04 -0600)
From: Norman Palardy

On Jun 25, 2004, at 5:45 PM, James Milne wrote:

>
> On 25 Jun, 2004, at 19:27, Joseph J. Strout wrote:
>
>> At 7:05 PM +0200 6/25/04, Christian Schmitz wrote:
>>
>>> > This can't be copied-and-pasted code... it doesn't even look like
>>>> valid C code to me. What's with the extra quotes around some of
>>>> your
>>>> types?
>>>
>>> constants.
>>> All the class names are constants so I don't make type errors.
>>
>> Ah. Sneaky.
>>
>> In that case, the only difference I can see between the one that
>> works and the one that doesn't, is that the latter has a parameter of
>> type CFDictionary. Could it be that CFDictionary has not yet been
>> registered at the time this class extension is being registered?
>
> No- I've had precisely the same problem with plugins before, and I'm
> buggered if I can figure out what it is.
>
> I was defining class names in this form:
>
> const char* szClassName = "SomeClass";
>
> If you pass szClassName in as the name of your class to an RB struture,
> RB will crash when it loads the plugin. However, if you define your
> value using, for example, a #define, it works ok; ie:
>
> #define szClassName "SomeClass"
>
> I can only presume there must be something strange about such
> string constants, whether it be that they require static
> initialisation to fix up their pointer or something. But they
> don't work when you pass them into RB definition structures.

In the default SDK static initializers do not get run so your get hosed
this way.
If you used Thomas' modified one he did change it to call static
initializers once upon a time.

Not sure why REAL doesn't make a similar change but I recall there
being a reason.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Strange crashes with registering class extension
Date: 26.06.04 01:35 (Sat, 26 Jun 2004 02:35:44 +0200)
From: Christian Schmitz
Norman Palardy <<email address removed>> wrote:

> In the default SDK static initializers do not get run so your get hosed
> this way.

Maybe someone can post a note on what to change for this?

Mfg
Christian

Re: Strange crashes with registering class extension
Date: 26.06.04 02:06 (Fri, 25 Jun 2004 19:06:11 -0600)
From: Norman Palardy

On Jun 25, 2004, at 6:35 PM, Christian Schmitz wrote:

> Norman Palardy <<email address removed>> wrote:
>
>> In the default SDK static initializers do not get run so your get
>> hosed this way.
>
> Maybe someone can post a note on what to change for this?

Thomas Tempelmann's SDK had the code to do it.

The last time this came up the discussion was as follows

>
> On 14 Jan 2004, at 15:04, Thomas Tempelmann wrote:
>
>> Joe wrote:
>>
>>>> And .... why doesn't real do this ?
>>>> It can't be that big a change is it ?
>>>
>>> Yes, actually it can. Getting the static initializers to fire
>>> correctly is very compiler- and platform-dependent. We don't rely on
>>> them, and we don't want you to either, since even if you can get it
>>> to work now, I'm not at all confident that you'll always be able to.
>>> You're much better off writing code without them, in our opinion.
>>
>> I would say it is the other way around:
>> What RB does is quite wrong because the way it initializes
>> the CW runtime system is by calling undocumented functions.
>> And the reason why static constructors and exce handling
>> does not work is because the WRONG internal function is called.
>> The documented and well-supported way is to tell the linker
>> to call "initialize" instead of making an internal function
>> call from within your own init code. And that´s exactly what
>> my plugin does.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Strange crashes with registering class extension
Date: 26.06.04 02:45 (Fri, 25 Jun 2004 20:45:02 -0500)
From: Joseph J. Strout
At 2:35 AM +0200 6/26/04, Christian Schmitz wrote:

> > In the default SDK static initializers do not get run so your get hosed
>> this way.
>
>Maybe someone can post a note on what to change for this?

That wouldn't affect the code you're using. I think the problem must
be something else.

Best,
- Joe