CameraPlugin segmentation fault on 64-bit Linux

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

CameraPlugin segmentation fault on 64-bit Linux

Daniel Drake-2
 
Hi,

Scratch crashes on 64-bit Linux when attempting to use the webcam:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000421fdb in lookupMethodInClass (class=<optimized out>)
    at /usr/src/packages/BUILD/squeak-vm-app-4.10.2.2614/build-tree/gnu-interp.c:13387
13387 /usr/src/packages/BUILD/squeak-vm-app-4.10.2.2614/build-tree/gnu-interp.c:
No such file or directory.
(gdb) bt
#0  0x0000000000421fdb in lookupMethodInClass (class=<optimized out>)
    at /usr/src/packages/BUILD/squeak-vm-app-4.10.2.2614/build-tree/gnu-interp.c:13387
#1  0x0000000000427907 in interpret ()
    at /usr/src/packages/BUILD/squeak-vm-app-4.10.2.2614/build-tree/gnu-interp.c:9287
#2  0x00000000004125cf in main (argc=<optimized out>, argv=0x7ffc2aca0338,
    envp=<optimized out>)
    at /usr/src/packages/BUILD/squeak-vm-app-4.10.2.2614/unix/vm/sqUnixMain.c:1460

This has been discussed before, but as far as I can see there is no news:
http://lists.squeakfoundation.org/pipermail/vm-dev/2014-April/015020.html
http://bugs.squeak.org/view.php?id=7816


Apparently the CameraPlugin needs to be ported to be 64-bit
compatible. Are there any examples in the squeak-vm svn history of
other plugins or code that have been ported similarly?

I'd like to have a go at fixing the crash. I don't have any experience
with squeak-vm internals, but I've fixed 32/64 problems in other
contexts, and I wonder if looking at another previously-fixed plugin
as an example would get me on my way.

Thanks
Daniel
Reply | Threaded
Open this post in threaded view
|

Re: CameraPlugin segmentation fault on 64-bit Linux

David T. Lewis
 
On Sat, Apr 29, 2017 at 08:33:11AM -0600, Daniel Drake wrote:

> Hi,
>
> Scratch crashes on 64-bit Linux when attempting to use the webcam:
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000421fdb in lookupMethodInClass (class=<optimized out>)
>     at /usr/src/packages/BUILD/squeak-vm-app-4.10.2.2614/build-tree/gnu-interp.c:13387
> 13387 /usr/src/packages/BUILD/squeak-vm-app-4.10.2.2614/build-tree/gnu-interp.c:
> No such file or directory.
> (gdb) bt
> #0  0x0000000000421fdb in lookupMethodInClass (class=<optimized out>)
>     at /usr/src/packages/BUILD/squeak-vm-app-4.10.2.2614/build-tree/gnu-interp.c:13387
> #1  0x0000000000427907 in interpret ()
>     at /usr/src/packages/BUILD/squeak-vm-app-4.10.2.2614/build-tree/gnu-interp.c:9287
> #2  0x00000000004125cf in main (argc=<optimized out>, argv=0x7ffc2aca0338,
>     envp=<optimized out>)
>     at /usr/src/packages/BUILD/squeak-vm-app-4.10.2.2614/unix/vm/sqUnixMain.c:1460
>
> This has been discussed before, but as far as I can see there is no news:
> http://lists.squeakfoundation.org/pipermail/vm-dev/2014-April/015020.html
> http://bugs.squeak.org/view.php?id=7816
>
>
> Apparently the CameraPlugin needs to be ported to be 64-bit
> compatible. Are there any examples in the squeak-vm svn history of
> other plugins or code that have been ported similarly?
>
> I'd like to have a go at fixing the crash. I don't have any experience
> with squeak-vm internals, but I've fixed 32/64 problems in other
> contexts, and I wonder if looking at another previously-fixed plugin
> as an example would get me on my way.
>
> Thanks
> Daniel

I don't think that the camera plugin was ever made 64-bit clean. A bug report
is at http://bugs.squeak.org/view.php?id=7816

This would be a good project for an interested volunteer :-)

Dave

Reply | Threaded
Open this post in threaded view
|

Re: CameraPlugin segmentation fault on 64-bit Linux

Daniel Drake-2
 
Hi Dave,

On Sat, Apr 29, 2017 at 9:58 AM, David T. Lewis <[hidden email]> wrote:
> I don't think that the camera plugin was ever made 64-bit clean. A bug report
> is at http://bugs.squeak.org/view.php?id=7816
>
> This would be a good project for an interested volunteer :-)

I'm an interested volunteer, knowledgeable of 32 vs 64 bit challenges
but with no squeak-vm experience. Can you briefly provide some
direction of where to start here?

Are there any other plugins that have previously been made 64-bit
clean? (Maybe there is a similar example in svn history and I can find
some direction from that.)

Thanks
Daniel
Reply | Threaded
Open this post in threaded view
|

Re: CameraPlugin segmentation fault on 64-bit Linux

David T. Lewis
 
On Sat, Apr 29, 2017 at 10:08:23AM -0600, Daniel Drake wrote:

> Hi Dave,
>
> On Sat, Apr 29, 2017 at 9:58 AM, David T. Lewis <[hidden email]> wrote:
> > I don't think that the camera plugin was ever made 64-bit clean. A bug report
> > is at http://bugs.squeak.org/view.php?id=7816
> >
> > This would be a good project for an interested volunteer :-)
>
> I'm an interested volunteer, knowledgeable of 32 vs 64 bit challenges
> but with no squeak-vm experience. Can you briefly provide some
> direction of where to start here?
>
> Are there any other plugins that have previously been made 64-bit
> clean? (Maybe there is a similar example in svn history and I can find
> some direction from that.)


Hi Daniel,

Great, thanks for looking into this!

SoundPlugin and SqueakSLL are examples of plugins that required updates
for 64-bit.

The majority of issues involve storage of 64-bit pointer values in 32-bit
integers. Usually this is fixed by providing correct type declarations
throughout the support code, and by making sure that the translated code
from the plugin class in VMMaker produces code with type declarations
that match the support code.

In the case of CameraPlugin, I would be inclined to start by looking at
the support code in platforms/unix/plugins/CameraPlugin/ to get an idea
of what the function declarations are (or should be). Look through it
for any type casts, usually these are a red flag for something you are
going to need to fix.

If everything looks good in platforms/[unix|win32|Moc OS|iOS] then the
next thing to check will be the declarations in
platforms/Cross/plugins/CameraPlugin/CameraPlugin.h. These will probably
be ok, but make sure that anything declared as int is really a 32-bit
integer value.

If you are statisfied that the support code is all in good order for
compiling on 64-bits, then take a look at CameraPlugin in your VMMaker
image, and at it sgenerated source code in src/plugins/CameraPlugin/CameraPlugin.c.

Look for places in the generated code where the support code functions
are being called incorrectly, or where methods in the plugin itself
use default sqInt variable declarations that should be explicitly
declared as something else.

I do this sort of work using an interpreter VM on a 64-bit Linux
system because it lets me easily compile 64-bit VMs that run on
32-bit sqInt object memories, which is the combination that most
reliably finds type declaration problems.

You will probably want to run your VMs under gdb to locate problems,
but don't be afraid to hack some printf's into your generated plugin
source in order to find problems. Do a fflush after each printf
so you can see the output right before your VM crashes.

Thanks and HTH,
Dave

Reply | Threaded
Open this post in threaded view
|

Re: CameraPlugin segmentation fault on 64-bit Linux

Ben Coman
 


On Sun, Apr 30, 2017 at 2:21 AM, David T. Lewis <[hidden email]> wrote:

On Sat, Apr 29, 2017 at 10:08:23AM -0600, Daniel Drake wrote:
> Hi Dave,
>
> On Sat, Apr 29, 2017 at 9:58 AM, David T. Lewis <[hidden email]> wrote:
> > I don't think that the camera plugin was ever made 64-bit clean. A bug report
> > is at http://bugs.squeak.org/view.php?id=7816
> >
> > This would be a good project for an interested volunteer :-)
>
> I'm an interested volunteer, knowledgeable of 32 vs 64 bit challenges
> but with no squeak-vm experience. Can you briefly provide some
> direction of where to start here?
>
> Are there any other plugins that have previously been made 64-bit
> clean? (Maybe there is a similar example in svn history and I can find
> some direction from that.)


Hi Daniel,

Great, thanks for looking into this!

SoundPlugin and SqueakSLL are examples of plugins that required updates
for 64-bit.

The majority of issues involve storage of 64-bit pointer values in 32-bit
integers. Usually this is fixed by providing correct type declarations
throughout the support code, and by making sure that the translated code
from the plugin class in VMMaker produces code with type declarations
that match the support code.

In the case of CameraPlugin, I would be inclined to start by looking at
the support code in platforms/unix/plugins/CameraPlugin/ to get an idea
of what the function declarations are (or should be). Look through it
for any type casts, usually these are a red flag for something you are
going to need to fix.

If everything looks good in platforms/[unix|win32|Moc OS|iOS] then the
next thing to check will be the declarations in
platforms/Cross/plugins/CameraPlugin/CameraPlugin.h. These will probably
be ok, but make sure that anything declared as int is really a 32-bit
integer value.

If you are statisfied that the support code is all in good order for
compiling on 64-bits, then take a look at CameraPlugin in your VMMaker
image, and at it sgenerated source code in src/plugins/CameraPlugin/CameraPlugin.c.

Look for places in the generated code where the support code functions
are being called incorrectly, or where methods in the plugin itself
use default sqInt variable declarations that should be explicitly
declared as something else.

I do this sort of work using an interpreter VM on a 64-bit Linux
system because it lets me easily compile 64-bit VMs that run on
32-bit sqInt object memories, which is the combination that most
reliably finds type declaration problems.

You will probably want to run your VMs under gdb to locate problems,
but don't be afraid to hack some printf's into your generated plugin
source in order to find problems. Do a fflush after each printf
so you can see the output right before your VM crashes.

Thanks and HTH,
Dave


Some general background info...

A Tour of the Squeak Object Engine

Extending the Squeak Virtual Machine

cheers -ben
Reply | Threaded
Open this post in threaded view
|

Re: CameraPlugin segmentation fault on 64-bit Linux

timrowledge
 

> On 29-04-2017, at 8:25 PM, Ben Coman <[hidden email]> wrote:
>
> http://coweb.cc.gatech.edu/squeakbook/upload


Good grief, that version is so out of date it was written by knotting strings made of woven unicorn hair.

Try http://www.rowledge.org/resources/tim's-Home-page/Squeak/OE-Tour.pdf - ad even that is now horribly out of date. I wonder if I’ll ever have time to rewrite it.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: MTP: MounT Programmer


Reply | Threaded
Open this post in threaded view
|

Re: CameraPlugin segmentation fault on 64-bit Linux

timrowledge
 

> On 30-04-2017, at 10:02 AM, tim Rowledge <[hidden email]> wrote:
>
> Good grief, that version is so out of date it was written by knotting strings made of woven unicorn hair.

I see that that directory holds quite a few out  of date versions of the book content. It would be nice to clean up the list to avoid future confusion andI suspect it is very much orphaned anyway; gatech haven’t been big players in the Squeak world for some time now. It’s running on squeak 3.7 for goodness’ sake!

See http://coweb.cc.gatech.edu to get an idea of how old much of it is. I wonder if Mark G still uses his gatech email ...

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Quality assurance: A way to ensure you never deliver shoddy goods accidentally.


Reply | Threaded
Open this post in threaded view
|

Re: CameraPlugin segmentation fault on 64-bit Linux

Eliot Miranda-2
In reply to this post by Daniel Drake-2
 


_,,,^..^,,,_ (phone)

On Apr 29, 2017, at 9:08 AM, Daniel Drake <[hidden email]> wrote:


Hi Dave,

On Sat, Apr 29, 2017 at 9:58 AM, David T. Lewis <[hidden email]> wrote:
I don't think that the camera plugin was ever made 64-bit clean. A bug report
is at http://bugs.squeak.org/view.php?id=7816

This would be a good project for an interested volunteer :-)

I'm an interested volunteer, knowledgeable of 32 vs 64 bit challenges
but with no squeak-vm experience. Can you briefly provide some
direction of where to start here?

Hi Daniel,

this will get you started with building a tip VMMaker image:

http://www.mirandabanda.org/cogblog/build-image/

There is a glitch.  The scripts don't currently  download a vm for you but you can build your own in the context of the repository or you can download a vm from bintray or use the vm you're using now.  The script explains how to substitute a vm. 

There are workspaces in the image that the comatose n how to generate sources.

If you look in the archives for the list you should give me discussion of making sources 32-bit clean and using sqIntptr_t as the type for a parameter that takes a Smalltalk oop in both 32 and 64 bits.

It's likely that headers and support code that use int parameters have to be changed to use sqInt or sqIntptr_t, depending on whether they actually receive an oop or a pointer.  Mac & Linux are LP64, windows is LLP64.


Are there any other plugins that have previously been made 64-bit
clean? (Maybe there is a similar example in svn history and I can find
some direction from that.)

Thanks
Daniel
Reply | Threaded
Open this post in threaded view
|

Re: CameraPlugin segmentation fault on 64-bit Linux

timrowledge
 

> On 30-04-2017, at 1:07 PM, Eliot Miranda <[hidden email]> wrote:
>
> There are workspaces in the image that the comatose n how to generate sources.
>
Damn you Auto Cock-up!

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: RDRI: Rotate Disk Right Immediate


Reply | Threaded
Open this post in threaded view
|

Re: CameraPlugin segmentation fault on 64-bit Linux

Eliot Miranda-2
In reply to this post by Daniel Drake-2
 
How Daniel,

   second attempt to avoid autocorrect ...

On Apr 29, 2017, at 9:08 AM, Daniel Drake <[hidden email]> wrote:


Hi Dave,

On Sat, Apr 29, 2017 at 9:58 AM, David T. Lewis <[hidden email]> wrote:
I don't think that the camera plugin was ever made 64-bit clean. A bug report
is at http://bugs.squeak.org/view.php?id=7816

This would be a good project for an interested volunteer :-)

I'm an interested volunteer, knowledgeable of 32 vs 64 bit challenges
but with no squeak-vm experience. Can you briefly provide some
direction of where to start here?

Hi Daniel,

this will get you started with building a tip VMMaker image:

http://www.mirandabanda.org/cogblog/build-image/

There is a glitch.  The scripts don't currently  download a vm for you but you can build your own in the context of the repository or you can download a vm from bintray or use the vm you're using now.  The script explains how to substitute a vm. 

There are workspaces in the image that describe how to generate sources.

If you look in the archives for the list you should find discussion of making sources 32-bit clean and using sqIntptr_t as the type for a parameter that takes a Smalltalk oop in both 32 and 64 bits.

It's likely that headers and support code that use int parameters have to be changed to use sqInt or sqIntptr_t, depending on whether they actually receive an oop or a pointer.  The issue being, as I'm sure you're aware, that Mac & Linux are LP64, whereas windows is LLP64.


Are there any other plugins that have previously been made 64-bit
clean? (Maybe there is a similar example in svn history and I can find
some direction from that.)

Yes.  If you build a 64-bit vm you can see the plugins that have been built.  As David said, many plugins had to have their glue code, typically defined in platforms/Cross/plugins/SomePlugin/SomePlugin.h, redefined to be usable in both 32 and 64 bits.  In the old days int was used for almost everything.  I think I'm correct in thinks my that we've rewritten all the used plugins.  

And welcome!  It's great to have another set of hands.  Thank you!


Thanks
Daniel


_,,,^..^,,,_ (phone)