473,654 Members | 3,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

please help with mysterious error....

Hi,

In continuation of the thread I made "perhaps a stack problem? Long
calculations - strange error?", I think I now got a "stable" error,
meaning that the error always seem to come here now (tried: visual
studio 2005 + linux/macintosh gcc)...

That's a pretty good thing. I think the error still appears using both
gcc and visual studio 2005. Everything is standard C (ANSI C ?? I don't
know the difference) - but since so many functions depend on different
variables it's hard for me to isolate the error or to make a minimal
example ready for posting...

What can I say: I don't get any compile errors/warning... I tried
valgrind, but it wrote something I didn't agree with or I didn't
understood what it disliked...
Instructions:

1) Download + unzip (there are no binaries so no viruses/spam/whatever)
2a) Under linux/mac os: just type "make" (makefile included)
2b) Under windows: I guess you just create a new project and drag the
*.c and *.h files into it and compile/build.
3a) Either run the program and see the error or
3b) put a breakpoint in "result_output. c" line 748, then step a few
lines and watch what happens.

What is wrong?
for(i=0; i<total_linepie ces; i++);
{
printf("i = %d\n", i); /* i should be 0 now, right? */
if( i != 0)
{
printf("\n\nTHE PROGRAM DOESN'T WORK\n\n");
quit_program(__ FILE__, __LINE__);
}
else
{
printf("\n\nTHA NKS!!! THE PROGRAM WORKS\n");
quit_program(__ FILE__, __LINE__);
}
}

Some memory-garbage-thing, probably...
I'm really really fed up and tired of this bug, because I can't find it
and the compiler doesn't help me...

I've prepared 2 archives: .zip + .tar.gz.

(enter code + click blue button "START DOWNLOAD")
zip: http://www.uploading.com/?get=N3PT46TP

(click "DOWNLOAD", yellow bar bottom right).
tar.gz: http://www.savefile.com/files/2695995
It would also be nice to know how to avoid such a problem in the future,
when the compiler doesn't help...
Best regards
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
Jun 1 '06 #1
33 2850
Martin Jørgensen said:
Hi,

In continuation of the thread I made "perhaps a stack problem? Long
calculations - strange error?", I think I now got a "stable" error,
meaning that the error always seem to come here now (tried: visual
studio 2005 + linux/macintosh gcc)...


I got 92 lines of complaint from gcc.

Here are the edited highlights:

main.h:46: warning: declaration of `dx' shadows global declaration
main.h:47: warning: declaration of `dy' shadows global declaration

(lots and lots of similar diagnostics)

..//main.c:32: warning: passing arg 1 of `get_nx_ny_nz' discards qualifiers
from pointer target type
..//main.c:49: warning: passing arg 1 of `quit_program' discards qualifiers
from pointer target type

(lots and lots of similar diagnostics)

When you get a clean compile at a reasonably fascist warning level, come on
back.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jun 1 '06 #2
On Thu, 01 Jun 2006 18:17:12 +0200, Martin Jørgensen wrote:
Hi,

In continuation of the thread I made "perhaps a stack problem? Long
calculations - strange error?", I think I now got a "stable" error,
meaning that the error always seem to come here now (tried: visual
studio 2005 + linux/macintosh gcc)...

That's a pretty good thing. I think the error still appears using both
gcc and visual studio 2005. Everything is standard C (ANSI C ?? I don't
know the difference) - but since so many functions depend on different
variables it's hard for me to isolate the error or to make a minimal
example ready for posting...

What can I say: I don't get any compile errors/warning... I tried
valgrind, but it wrote something I didn't agree with or I didn't
understood what it disliked... <snip> What is wrong?
for(i=0; i<total_linepie ces; i++); I think you should remove the semicolon here, now this line just
increments i until it's equal to 'total_linepiec es', and afterwars the
following code gets executed.
{
printf("i = %d\n", i); /* i should be 0 now, right? */ if( i != 0) {
printf("\n\nTHE PROGRAM DOESN'T WORK\n\n"); quit_program(__ FILE__,
__LINE__);
}
else
{
printf("\n\nTHA NKS!!! THE PROGRAM WORKS\n"); quit_program(__ FILE__,
__LINE__);
}
}

Some memory-garbage-thing, probably...
I'm really really fed up and tired of this bug, because I can't find it
and the compiler doesn't help me... <snip>
It would also be nice to know how to avoid such a problem in the future,
when the compiler doesn't help...
Best regards
Martin Jørgensen


Hope this helps,
Bas Wassink
Jun 1 '06 #3
Bas Wassink wrote:
On Thu, 01 Jun 2006 18:17:12 +0200, Martin Jørgensen wrote:

Hi,

In continuation of the thread I made "perhaps a stack problem? Long
calculation s - strange error?", I think I now got a "stable" error,
meaning that the error always seem to come here now (tried: visual
studio 2005 + linux/macintosh gcc)...

That's a pretty good thing. I think the error still appears using both
gcc and visual studio 2005. Everything is standard C (ANSI C ?? I don't
know the difference) - but since so many functions depend on different
variables it's hard for me to isolate the error or to make a minimal
example ready for posting...

What can I say: I don't get any compile errors/warning... I tried
valgrind, but it wrote something I didn't agree with or I didn't
understood what it disliked...


<snip>
What is wrong?
for(i=0; i<total_linepie ces; i++);


I think you should remove the semicolon here, now this line just
increments i until it's equal to 'total_linepiec es', and afterwars the
following code gets executed.


OMFG! That code was driving me "#€%()#€%€(%##€ (#€%( crazy and then I
just overlooked that? :-)

I think I've looked many other places, but that... Oh, well. Nice to get
some feedback... Thanks.
Best regards
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
Jun 1 '06 #4
Richard Heathfield wrote:
Martin Jørgensen said:

Hi,

In continuation of the thread I made "perhaps a stack problem? Long
calculation s - strange error?", I think I now got a "stable" error,
meaning that the error always seem to come here now (tried: visual
studio 2005 + linux/macintosh gcc)...

I got 92 lines of complaint from gcc.


Ok, since this problem was just a semi-colon in the wrong place (C is
really a bitch to me sometimes, LOL) I have the feeling that my original
problem perhaps could have been that 2 of my variable arrays was
malloc'ed 2 bytes too small, each (the "perhaps a stack problem?-thing")...
Here are the edited highlights:

main.h:46: warning: declaration of `dx' shadows global declaration
main.h:47: warning: declaration of `dy' shadows global declaration

(lots and lots of similar diagnostics)

.//main.c:32: warning: passing arg 1 of `get_nx_ny_nz' discards qualifiers
from pointer target type
.//main.c:49: warning: passing arg 1 of `quit_program' discards qualifiers
from pointer target type

(lots and lots of similar diagnostics)

When you get a clean compile at a reasonably fascist warning level, come on
back.


Eerhm, please help me get to know how I get so many warnings printed out
so I can fix them... I don't get any if I just type make.

How did you compile (detailed instructions, please)...

I was told that just typing "make" was sufficient (I didn't make the
makefile myself), but I also had the feeling that much more was wrong...

I was actually also wondering why that global variable definitions
didn't work... :-)
Best regards
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
Jun 1 '06 #5
Richard Heathfield wrote:
Martin Jørgensen said: -snip-
When you get a clean compile at a reasonably fascist warning level, come on
back.


Erhm, even better yet: How do I make a/modify my makefile so the program
gets compiled with the highest warning/error-output level every time?

Basically I just want something where I just type "make" and then I see
all (92 lines of or whatever..) warnings/errors?

Then I fix some of them and type "make" again until they're all gone...
Best regards
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
Jun 1 '06 #6
Martin Jørgensen wrote:
Richard Heathfield wrote:
Martin Jørgensen said: -snip-
When you get a clean compile at a reasonably fascist warning level, come on
back.


Erhm, even better yet: How do I make a/modify my makefile so the program
gets compiled with the highest warning/error-output level every time?


The documentation for your compiler will detail the command line flags
needed to set diagnostics level.

If you're using gcc, type info gcc under Linux or download the docs
available from gcc.gnu.org and read them.

A minimal set of switches is -W -Wall -ansi -pedantic. Richard
Heathfield posted recently a set of switches he uses to get even more
checking and diagnostics. Use Google Groups to search for it.

Once you get the command line right, you can then create your makefile.
To do that, GNU make's docs contain a tutorial.
Basically I just want something where I just type "make" and then I see
all (92 lines of or whatever..) warnings/errors?

Then I fix some of them and type "make" again until they're all gone...


As an alternative a graphical IDE might suit your needs, provided it
supplies options to pass to the compiler.

Jun 1 '06 #7
Martin Jørgensen said:
How did you compile (detailed instructions, please)...


I used your makefile (much against my better judgement), but changed:

CFLAGS = $(PROTO_DEFINES ) $(STD_DEFINES) -g

to

CFLAGS = $(PROTO_DEFINES ) $(STD_DEFINES) -g -W -Wall -ansi -pedantic
-Wformat-nonliteral -Wcast-align -Wpointer-arith -Wbad-function-cast
-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Winline
-Wundef -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2

(all on one line, obviously).

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jun 1 '06 #8
Martin Jørgensen said:
Richard Heathfield wrote:
Martin Jørgensen said: -snip-
When you get a clean compile at a reasonably fascist warning level, come
on back.


Erhm, even better yet: How do I make a/modify my makefile so the program
gets compiled with the highest warning/error-output level every time?


I have already demonstrated this elsethread.
Basically I just want something where I just type "make" and then I see
all (92 lines of or whatever..) warnings/errors?

Then I fix some of them and type "make" again until they're all gone...


I have a little program called makegen, which generates a makefile on
standard output. The simplest possible usage is:

makegen foo

Its output (which can of course be redirected to a Makefile) is:

CC=gcc
CFLAGS=-W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-Wno-conversion -ffloat-store -O2
DFLAGS=-g -pg
foo: foo.o
$(CC) $(CFLAGS) $(DFLAGS) -o foo foo.o
foo.o: foo.c
$(CC) $(CFLAGS) $(DFLAGS) -c -o foo.o foo.c

clean:
rm foo.o
rm foo

install:
cp foo /usr/local/bin

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jun 1 '06 #9
Martin Jørgensen wrote:
Richard Heathfield wrote:
Martin Jørgensen said:

-snip-
When you get a clean compile at a reasonably fascist warning level,
come on back.


Erhm, even better yet: How do I make a/modify my makefile so the program
gets compiled with the highest warning/error-output level every time?

Basically I just want something where I just type "make" and then I see
all (92 lines of or whatever..) warnings/errors?

Then I fix some of them and type "make" again until they're all gone...


That depends on your compiler and make system (it would not be the same
for all the systems I use). Ask in a group that deals with your tool set.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Jun 1 '06 #10

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

Similar topics

3
2662
by: dixie | last post by:
I have an Access 2000 form which has been running OK for a long time. Lately, it is playing up and doing things like causing Access to close suddenly when the form is opened or when saving the form in design view after a change. Today, I got the following message from the form when using a combo box. "The expression After Update you entered as the event property setting produced the following error: A problem occurred while Microsoft...
13
2428
by: Max | last post by:
Hi There! I'm having a mysterious error right after I login using Forms Authentication in my ASP.NET app. Below is the error... Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. The exception throws at the code that tries to set a property (String data type) at my Menu user control.
4
2755
by: mark4asp | last post by:
I want to write a xslt template to create a xhtml 1.0 (transitional) file which will be sent in as email. Here is a typical xml data file: <BatchEmail> <Domain>www.myDomain.com</Domain> <Destination> <Salutation>Hi Mark</Salutation> <UniqueID>4120</UniqueID>
1
2405
by: cousinoer5 | last post by:
I'm trying to implement a shop in my game, right now I can buy anything in the shop and it works perfectly, but I can't sell anything because I get an error I can't figure out. Here's the relevent code: def shop(self, name): self.name = name if name == "sapphire": if "sapphire" in self.inventory: print "I can buy that for 10 gold." self.inventory.remove_item("sapphire")
0
8379
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8294
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8709
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8494
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.