Menu

#9 running error on freebsd

closed-works-for-me
None
5
2000-12-27
2000-10-25
Ting Wan
No

Script started on Wed Oct 25 11:07:11 2000
> ./outline

Segmentation fault(core dumped)

> gdb outline

GNU gdb 4.18

Copyright 1998 Free Software Foundation, Inc.

GDB is free software, covered by the GNU General Public License, and you are

welcome to change it and/or distribute copies of it under certain conditions.

Type "show copying" to see the conditions.

There is absolutely no warranty for GDB. Type "show warranty" for details.

This GDB was configured as "i386-unknown-freebsd"...

(gdb) b 42

Breakpoint 1 at 0x80486f4: file outline.c, line 42.

(gdb) r

Starting program: /usr/home/twan/XMLparser/expat-1.95.1/examples/outline

Program received signal SIGSEGV, Segmentation fault.

0x280f109e in memcpy () from /usr/lib/libc.so.4

(gdb) b 85

Breakpoint 2 at 0x80487fc: file outline.c, line 85.

(gdb) R

The program being debugged has been started already.

Start it from the beginning? (y or n) y

Starting program: /usr/home/twan/XMLparser/expat-1.95.1/examples/outline

Breakpoint 2, main (argc=1, argv=0xbfbffb6c) at outline.c:85

85 XML_SetElementHandler(p, start, end);

(gdb) n

86 XML_SetCharacterDataHandler(p,charhndl);

(gdb) n

87 for (;;) {

(gdb) n

107 }

(gdb) n

92 if (ferror(fp)) {

(gdb) n

96 done = feof(fp);

(gdb) n

98 if (! XML_Parse(p, Buff, len, done)) {

(gdb) s

0x8048540 in XML_Parse () at xmlparse.c:1083

1083 {

(gdb) n

0x8048546 1083 {

(gdb) n

0x804854b 1083 {

(gdb)

0x8048510 in _init ()

(gdb)

Single stepping until exit from function _init,

which has no line number information.

Program received signal SIGSEGV, Segmentation fault.

0x280f109e in memcpy () from /usr/lib/libc.so.4

(gdb) q

The program is running. Exit anyway? (y or n) y

> more outline/.c

/*****************************************************************

* outline.c

*

* Copyright 1999, Clark Cooper

* All rights reserved.

*

* This program is free software; you can redistribute it and/or

* modify it under the terms of the license contained in the

* COPYING file that comes with the expat distribution.

*

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,

* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF

* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY

* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,

* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*

* Read an XML document from standard input and print an element

* outline on standard output.

*/

#include <stdio.h>

#include </usr/local/include/expat.h>

#define BUFFSIZE 8192

char Buff[BUFFSIZE];

char str[1000];

int Depth;

void charhndl(void *userData,

const XML_Char* s,

int len)

{

int i;

char* str;

if(len>1)

{

//str=malloc(len+1);

strncpy(str,s,len);

// for(i=0;i<len;i++)

// str[i]='a';

str[len]='\0';

//str=s+len+1;

//str=s;

//*(str+len)='\0';

printf("%s\n",str);

i=1;

}

}

void

start(void *data, const char *el, const char **attr) {

int i;

for (i = 0; i < Depth; i++)

printf(" ");

printf("%s", el);

for (i = 0; attr[i]; i += 2) {

printf(" %s='%s'", attr[i], attr[i + 1]);

}

printf("\n");

Depth++;

} /* End of start handler */

void

end(void *data, const char *el) {

Depth--;

} /* End of end handler */

main(int argc, char **argv) {

XML_Parser p;

FILE* fp;

fp=fopen("smil.xml","r");

p = XML_ParserCreate(NULL);

if (! p) {

fprintf(stderr, "Couldn't allocate memory for parser\n");

exit(-1);

}

XML_SetElementHandler(p, start, end);

XML_SetCharacterDataHandler(p,charhndl);

for (;;) {

int done;

int len;

len = fread(Buff, 1, BUFFSIZE, fp);

if (ferror(fp)) {

fprintf(stderr, "Read error\n");

exit(-1);

}

done = feof(fp);

if (! XML_Parse(p, Buff, len, done)) {

fprintf(stderr, "Parse error at line %d:\n%s\n",

XML_GetCurrentLineNumber(p),

XML_ErrorString(XML_GetErrorCode(p)));

exit(-1);

}

if (done)

break;

}

} /* End of main */

> more smil.xml

<?xml version="1.0" standalone="no"?>

<!--

Example for SMIL (Synchronized Multimedia Integration Language)

see http://www.w3.org/TR/WD-smil for more information

-->

<!DOCTYPE smil SYSTEM "smil.dtd">

<smil>

<head>

<layout type="text/smil-basic">

<channel id="left-video" left="20" top="50" z-index="1"/>

<channel id="left-text" left="20" top="120" z-index="1"/>

<channel id="right-video" left="150" top="50" z-index="1"/>

<channel id="right-text" left="150" top="120" z-index="1"/>

</layout>

</head>

<body>

<par>

<img src="bg"/>

<seq>

<par>

<img src="graph" channel="left-video" dur="60s"/>

<text src="graph-text" channel="left-text"/>

</par>

<par>

<a href="http://www.w3.org/People/Berners-Lee">

<video src="tim-video" channel="left-video"/>

<text src="tim-text" channel="left-text"/>

</a>

</par>

</seq>

<seq>

<audio src="joe-audio"/>

<audio src="tim-audio"/>

</seq>

<video id="jv" src="joe-video" channel="right-video"/>

<text src="joe-text" channel="right-text"/>

</par>

</body>

</smil>

exit

Script done on Wed Oct 25 11:10:48 2000

Discussion

  • Clark Cooper

    Clark Cooper - 2000-12-27

    Tried this on an OpenBsd system and could not get seg error.

    I did a ./configure --prefix=$HOME/build and then did a make and install. The Makefile in examples directory does not work, so had to
    do the following:

    make CPPFLAGS=-I$HOME/build/include LDFLAGS=-L$HOME/build/lib

    Then to use the outline executable, had to set LD_LIBRARY_PATH:

    setenv LD_LIBRARY_PATH $HOME/build/lib

    Then worked with the provided SMIL file without error.

    I'll look at making the Makefile work. This may be your problem.

     
  • Clark Cooper

    Clark Cooper - 2000-12-27
    • assigned_to: nobody --> coopercc
    • status: open --> closed-works-for-me
     

Log in to post a comment.