Newbie question: segmentation fault

Newbie question: segmentation fault

Post by Jean-Michel LEON-FOUN-L » Sun, 13 Jul 2003 00:33:47



Hi,

what does it mean when the execution of a Renderman program is
interrupted with the following message: "segmentation fault"?

I'm a newbie to Renderman, and programing in general, so thanks in
advance for your much needed help.

I use 3Delight 1.0.6 (beta) on Mac OS X 10.2.6.

Here is the code for the program (adapted from Ian Stephenson's) which
compiles fine :

--------------------------------------------

/* sphere.c - Create a sphere with a shader - Use of a light handle */

#include <ri.h>

int main(int argc, char *argv[])
{
RtColor blue={0,0,1};

RtFloat diffuse=1;
RtFloat direct=0.5;
RtColor directcolor={1,1,1};
RtFloat ambient=0.5;

RtLightHandle light;
RtPoint lightposition={-1,1,-1};
RtFloat lightintensity=5;

RiBegin(RI_NULL);

    RiDisplay("sphere_plastic11.tiff","file","rgb",RI_NULL);
    RiProjection("perspective",RI_NULL);
    RiTranslate(0,0,2);

    RiWorldBegin();

        light=RiLightSource("pointlight",
                            "from",lightposition,
                            "intensity",lightintensity,
                            RI_NULL);
                RiColor(blue);
                RiSurface("plastic",
                          "Kd",diffuse,
                          "Ks",direct,"specularcolor",directcolor,
                          "Ka",ambient,
                  RI_NULL);
        RiSphere(1,-1,1,360,RI_NULL);

    RiWorldEnd();

RiEnd();
return 0;

Quote:}

--------------------------------------------
 
 
 

Newbie question: segmentation fault

Post by Ian Stephenso » Sun, 13 Jul 2003 02:37:22



> Hi,

> what does it mean when the execution of a Renderman program is
> interrupted with the following message: "segmentation fault"?

This means that the program has attempted to access some memory which it
shouldn't. In RenderMan terms this almost invariably has something to do
with parameter lists - most oftern that you've forgotten the RI_NULL.

In this case you need to rememeber that all of the parameters need to be
passed as pointers. Vectors and Colours are not a problem, as these are
passed to functions as pointers anyway. However for scaler values you
need to add an "&" before them in the paramters lists (in the book I
demonstrate this with "fov", as a param to the projection call).

$an

Quote:

> /* sphere.c - Create a sphere with a shader - Use of a light handle */

> #include <ri.h>

> int main(int argc, char *argv[])
> {
> RtColor blue={0,0,1};

> RtFloat diffuse=1;
> RtFloat direct=0.5;
> RtColor directcolor={1,1,1};
> RtFloat ambient=0.5;

> RtLightHandle light;
> RtPoint lightposition={-1,1,-1};
> RtFloat lightintensity=5;

> RiBegin(RI_NULL);

>     RiDisplay("sphere_plastic11.tiff","file","rgb",RI_NULL);
>     RiProjection("perspective",RI_NULL);
>     RiTranslate(0,0,2);

>     RiWorldBegin();

>         light=RiLightSource("pointlight",
>                             "from",lightposition,
>                             "intensity",&lightintensity,

INERTED &                            HERE ^

Quote:>                             RI_NULL);
>                 RiColor(blue);
>                 RiSurface("plastic",
>                           "Kd",&diffuse,

INERTED &                   HERE ^

Quote:>                           "Ks",&direct,"specularcolor",directcolor,

INERTED &                   HERE ^

Quote:>                           "Ka",&ambient,

INERTED &                   HERE ^

- Show quoted text -

Quote:>                   RI_NULL);
>         RiSphere(1,-1,1,360,RI_NULL);

>     RiWorldEnd();

> RiEnd();
> return 0;
> }

> --------------------------------------------


 
 
 

Newbie question: segmentation fault

Post by Jean-Michel LEON-FOUN-L » Sun, 13 Jul 2003 11:02:06


Hi Ian,

thanks a lot for your help, I was stuck with this little program. Now  I
know I have to pay attention to details when programming!

And by the way, I love your book (Essential Renderman Fast). I also have
The Companion and Advanced Renderman, but I am learning Renderman in
yours first as it is less theoretical and more geared towards practice,
with immediate results. But the three books are complementary of course.

For a newbie and amateur like me, it is very gratifying to write a RIB
file or a C program and see that it actually works! Right now I'm on
chapter 16 and 17 (C API and Particles and Hair), then I will get to the
second big part, Shading.

Maybe I could need your help again, if you don't mind.

Thanks again.



> > Hi,

> > what does it mean when the execution of a Renderman program is
> > interrupted with the following message: "segmentation fault"?

> This means that the program has attempted to access some memory which it
> shouldn't. In RenderMan terms this almost invariably has something to do
> with parameter lists - most oftern that you've forgotten the RI_NULL.

> In this case you need to rememeber that all of the parameters need to be
> passed as pointers. Vectors and Colours are not a problem, as these are
> passed to functions as pointers anyway. However for scaler values you
> need to add an "&" before them in the paramters lists (in the book I
> demonstrate this with "fov", as a param to the projection call).

> $an

> > /* sphere.c - Create a sphere with a shader - Use of a light handle */

> > #include <ri.h>

> > int main(int argc, char *argv[])
> > {
> > RtColor blue={0,0,1};

> > RtFloat diffuse=1;
> > RtFloat direct=0.5;
> > RtColor directcolor={1,1,1};
> > RtFloat ambient=0.5;

> > RtLightHandle light;
> > RtPoint lightposition={-1,1,-1};
> > RtFloat lightintensity=5;

> > RiBegin(RI_NULL);

> >     RiDisplay("sphere_plastic11.tiff","file","rgb",RI_NULL);
> >     RiProjection("perspective",RI_NULL);
> >     RiTranslate(0,0,2);

> >     RiWorldBegin();

> >         light=RiLightSource("pointlight",
> >                             "from",lightposition,
> >                             "intensity",&lightintensity,
> INERTED &                            HERE ^

> >                             RI_NULL);
> >                 RiColor(blue);
> >                 RiSurface("plastic",
> >                           "Kd",&diffuse,
> INERTED &                   HERE ^

> >                           "Ks",&direct,"specularcolor",directcolor,
> INERTED &                   HERE ^

> >                           "Ka",&ambient,
> INERTED &                   HERE ^

> >                   RI_NULL);
> >         RiSphere(1,-1,1,360,RI_NULL);

> >     RiWorldEnd();

> > RiEnd();
> > return 0;
> > }

> > --------------------------------------------

 
 
 

1. RiObject Causes segmentation fault.

I am compiling a C file to generate a rib file on Linux (g++ -lribout
...). If I call the function, it gives me a segmentation fault when I
run the program. The function call is this:
   RiOption("searchpath", "shader", ".:../examples:&");
Any ideas?

Thanks,
Rob Mosher

2. XY data -> .GIF Graphs. Unix tool or lib avail?

3. segmentation fault(core dumped)

4. question about gnuplot

5. ?? Direct illum at vertices...Segmentation fault (core dumped)

6. Transforming Planes

7. BMRT & Segmentation Fault

8. glutMotionFunc causes segmentation fault in video programming

9. segmentation fault (error code 139)

10. Segmentation fault in the bowels of Inventor

11. Segmentation faults

12. Segmentation faults and other graphics problems