473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

can some one please tell me the cause of the error ?

Hello, I am trying to write a library for buildding a kdtree for the
3d mesh. I have uploaded my code on:

http://www.uploading.com/files/LW2EJYPK/code.zip.html

Out of the four modules in the program, kdtree.c is the only one which
is failing at line number 162 , subdivide_kdtree function( I found
this by using some printf statements and checking values). This is the
statement that's failing:

kd->child[i]->ntriangles += 1;

Why is this happening ?? My machine is running low on memory at the
moment, could it because of that ? Can some one else please verify if
this is the problem ?
Jun 27 '08 #1
9 1209
On Jun 25, 11:05*am, pereges <Brol...@gmail.comwrote:
*Hello, I *am trying to write a library for buildding a kdtree for the
3d mesh. I have uploaded my code on:

http://www.uploading.com/files/LW2EJYPK/code.zip.html

Out of the four modules in the program, kdtree.c is the only one which
is failing at line number 162 , subdivide_kdtree function( I found
this by using some printf statements and checking values). This is the
statement that's failing:

kd->child[i]->ntriangles += 1;

Why is this happening ?? My machine is running low on memory at the
moment, could it because of that ? Can some one else please verify if
this is the problem ?
What do you mean by "failing"? How do you *know* it has failed?
Does it not compile?
Does it crash when executed?
Does it add 3 instead of 1?
Is the value of "i" out of range?
Has child[i] been initialized to point to a valid struct?
--
Fred Kleinschmidt
Jun 27 '08 #2
On Jun 26, 12:31 am, Fred <fred.l.kleinschm...@boeing.comwrote:
What do you mean by "failing"? How do you *know* it has failed?
Does it not compile?
Does it crash when executed?
Does it add 3 instead of 1?
Is the value of "i" out of range?
Has child[i] been initialized to point to a valid struct?
1. The process abnormally terminates and reutrns a non-zero value.
2. It compiles.
3. No it adds only 1 and increments the value of kd->child[i]-
>ntriangles which was initialized to zero.
4. No, it has values 0 and 1.
5. Yes, space has been allocated for child[i] using malloc.

Jun 27 '08 #3
On Wed, 25 Jun 2008 12:52:03 -0700, pereges wrote:
On Jun 26, 12:31 am, Fred <fred.l.kleinschm...@boeing.comwrote:
>>[context: pereges wrote:]
>>This is the statement that's failing:

kd->child[i]->ntriangles += 1;

What do you mean by "failing"? How do you *know* it has failed?
[...]
Does it add 3 instead of 1?

The process abnormally terminates and reutrns a non-zero value.
[...]
No it adds only 1 and increments the value of kd->child[i]
->ntriangles which was initialized to zero.
Which is it? Does the process abnormally terminate, or is kd->child[i]
->ntriangles incremented? Or do you mean that the process abnormally
terminates some time after ntriangles is incremented?
Jun 27 '08 #4
On Jun 26, 1:11 am, Harald van D©¦k <true...@gmail.comwrote:
Which is it? Does the process abnormally terminate, or is kd->child[i]
->ntriangles incremented? Or do you mean that the process abnormally
terminates some time after ntriangles is incremented?
The process abnormally terminates and i think it happens when it
encounters the statement:

kd->child[i]->ntriangles += 1 after a certain number of passes.

Jun 27 '08 #5
In article <e3**********************************@g16g2000pri. googlegroups.com>,
pereges <Br*****@gmail.comwrote:
>On Jun 26, 1:11 am, Harald van D=A9=A6k <true...@gmail.comwrote:
>Which is it? Does the process abnormally terminate, or is kd->child[i]
->ntriangles incremented? Or do you mean that the process abnormally
terminates some time after ntriangles is incremented?
>The process abnormally terminates and i think it happens when it
encounters the statement:
>kd->child[i]->ntriangles += 1 after a certain number of passes.
First pass guess is that it happens when i becomes equal to
the length of the kd->child matrix. C matrices are indexed from
0 to (the length minus one)
--
"The study of error is not only in the highest degree
prophylatic, but it serves as a stimulating introduction to the
study of truth." -- Walter Lipmann
Jun 27 '08 #6
pereges <Br*****@gmail.comwrites:
Hello, I am trying to write a library for buildding a kdtree for the
3d mesh. I have uploaded my code on:

http://www.uploading.com/files/LW2EJYPK/code.zip.html

Out of the four modules in the program, kdtree.c is the only one which
is failing at line number 162 , subdivide_kdtree function( I found
this by using some printf statements and checking values). This is the
statement that's failing:

kd->child[i]->ntriangles += 1;

Why is this happening ?? My machine is running low on memory at the
moment, could it because of that ? Can some one else please verify if
this is the problem ?
I see a different problem. valgrind reports an error (illegal write)
at line 178 of kdtree.c. If we look there we see:

kd->child[i]->vertexlist = malloc(sizeof(vector *) * (kd->child[i]->nvertices));
k = 0;
for(j = 0; j < kd->nvertices; j++)
{
if(vertex_inside_box(kd->vertexlist[j], kd->split, axis, i))
kd->child[i]->vertexlist[k] = kd->vertexlist[j]; /* 178 */
k += 1;
}

This looks suspicious. I'd expect the k += 1 to be in the body of the
'if'. Do you really want to leave some of the pointers uninitialised?
The normal idiom for this is to put k++ in index:

kd->child[i]->vertexlist[k++] = kd->vertexlist[j];

and loose the k += 1;.

Also, you allocate space for kd->child[i]->nvertices vector pointers but the
loop runs for kd->nvertices. If I am right about the k++, you need to
be sure that no more than kd->child[i]->nvertices of the kd->nvertices
vertexes pass the condition.

--
Ben.
Jun 27 '08 #7
pereges <Br*****@gmail.comwrites:
Hello, I am trying to write a library for buildding a kdtree for the
3d mesh. I have uploaded my code on:

http://www.uploading.com/files/LW2EJYPK/code.zip.html
This shows a big green "Download" button. The corresponding URL is
860 characters long. I'm not willing to click it.
Out of the four modules in the program, kdtree.c is the only one which
is failing at line number 162 , subdivide_kdtree function( I found
this by using some printf statements and checking values). This is the
statement that's failing:

kd->child[i]->ntriangles += 1;

Why is this happening ?? My machine is running low on memory at the
moment, could it because of that ? Can some one else please verify if
this is the problem ?
Reduce your code to a small example that exhibits the problem, and
post that. Also, tell us exactly *how* it fails: what output does it
produce, what did you expect, and how do these differ?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #8
On Jun 25, 11:05 pm, pereges <Brol...@gmail.comwrote:
Hello, I am trying to write a library for buildding a kdtree for the
3d mesh. I have uploaded my code on:

http://www.uploading.com/files/LW2EJYPK/code.zip.html

Out of the four modules in the program, kdtree.c is the only one which
is failing at line number 162 , subdivide_kdtree function( I found
this by using some printf statements and checking values). This is the
statement that's failing:

kd->child[i]->ntriangles += 1;

Why is this happening ?? My machine is running low on memory at the
moment, could it because of that ? Can some one else please verify if
this is the problem ?
It would help if you are specific how the program fails. If under
windows, does it says something like "send error report"?If linux, is
it a segmentation fault? Try running lint on your source code and
valgrind on your executable(if under linux) or equivalent if on some
other problem.

It would help everyone to get to the root of the problem if you
produce the faulty snippet along with the error messages. More people
will help you if they don't have to download and build something.
Jun 27 '08 #9
On Jun 26, 2:01 am, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
I see a different problem. valgrind reports an error (illegal write)
at line 178 of kdtree.c. If we look there we see:

kd->child[i]->vertexlist = malloc(sizeof(vector *) * (kd->child[i]->nvertices));
k = 0;
for(j = 0; j < kd->nvertices; j++)
{
if(vertex_inside_box(kd->vertexlist[j], kd->split, axis, i))
kd->child[i]->vertexlist[k] = kd->vertexlist[j]; /* 178 */
k += 1;
}

This looks suspicious. I'd expect the k += 1 to be in the body of the
'if'. Do you really want to leave some of the pointers uninitialised?
The normal idiom for this is to put k++ in index:

kd->child[i]->vertexlist[k++] = kd->vertexlist[j];

and loose the k += 1;.
thanks, this worked.

Also, you allocate space for kd->child[i]->nvertices vector pointers but the
loop runs for kd->nvertices. If I am right about the k++, you need to
be sure that no more than kd->child[i]->nvertices of the kd->nvertices
vertexes pass the condition.
The idea is distribute the vertices of the parent node (pointed to by
kd) among the child nodes (pointed to by kd->child[i] where i is 0 or
1). Yes, I must check that k == kd->child[i]->nvertices.
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Spikinsson | last post by:
I create a new char and when I attempt to delete it, the debug gives this error (during runtime): Debug Error! Program: xxx DAMAGE: after Normal block (#58) at 0x00C315A0.
4
by: Lloyd Sheen | last post by:
So MS where is the error that is reported on last line, says 1 failed. No indication as to what failed. VS 2003, (reinstalled more times than should have been). ------ Build started: Project:...
15
by: tabonni | last post by:
I want to check each button groups and save the checked value into a 2 dimensional array. But, it doesn't work. Could anyone tell me what's wrong with my code. My code is as follow: <html>...
2
by: Amanda | last post by:
From a guy in Microsoft newsgroups: | In *comp.databases.ibm-db2* there are always IBM guys | from the Toronto labs on line.Post with the | -for the love of god please help- | line...
2
by: Fredrik | last post by:
Im getting: "An unhandled exception of type 'System.NullReferenceException' occurred in system.dll Additional information: Object reference not set to an instance of an object." The error is...
4
by: Nick Weg | last post by:
Hello We have a web application developed in .NET using VB.NET. We get the error below every now and then and can't figure out how to correct it. The viewstate this error refers to is pretty...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
15
by: Giggle Girl | last post by:
Hello there, :) I need a frameset that will have the same look and behavior in Firefox 1.5+ as it does in IE 6+. Here is a URL for it: http://66.51.164.93/fs/default.htm In IE, the "seam"...
2
by: kavyak | last post by:
This is not a mere error. because,whatever input i give from jsp, its getting updated in mysql but the page is showing some internal error.The error looks like this.Plz tell me if someone knows the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.