Weird printf() crash and Watcom Debugger problems

I’m working on a program which worked fine right up until yesterday. It
uses a library which I’ve written to access files in a particular
format.

I added a function to the library yesterday and everything builds fine,
I even turned compiler warnings up to full to check for subtle problems.

However when I include the new library function in my test program it
crashes (‘access violation’) at the first printf. If I don’t use the
new function there’s no crash.

I’ve checked that it is printf that’s crashing, if I comment out the
first one the crash happens at the next (which is just printf("\n")),
according to Watcom’s debugger no printf code even starts to execute,
the crash is at the call to printf.

I had a look at the assembly as it executed and the crash occurs in the
‘push 00012084’ instruction which is executed immediately before ‘call
printf_’.

As a further question: why can’t I see the local variables in main() in
Watcom debugger. Other functions all have visible local variables but
main() just has an empty locals window.

Kev.

Previously, Kevin O’Rourke wrote in qdn.public.qnx4:

I had a look at the assembly as it executed and the crash occurs in the
‘push 00012084’ instruction which is executed immediately before ‘call
printf_’.

Not enough stack space? What happens if you turn on stack checking?
What happens if you increase the stack size?

As a further question: why can’t I see the local variables in main() in
Watcom debugger. Other functions all have visible local variables but
main() just has an empty locals window.

I’m guessing: Did you compile main.c with -g1?

Andrew

OK, how do I turn on stack checking?

I compiled with -g3.

Andrew Thomas wrote:

Previously, Kevin O’Rourke wrote in qdn.public.qnx4:
I had a look at the assembly as it executed and the crash occurs in the
‘push 00012084’ instruction which is executed immediately before ‘call
printf_’.

Not enough stack space? What happens if you turn on stack checking?
What happens if you increase the stack size?

As a further question: why can’t I see the local variables in main() in
Watcom debugger. Other functions all have visible local variables but
main() just has an empty locals window.

I’m guessing: Did you compile main.c with -g1?

Andrew

“Kevin O’Rourke” <kio@pcmail.nerc-bas.ac.uk> wrote in message
news:3A9D3456.5C98502B@pcmail.nerc-bas.ac.uk

OK, how do I turn on stack checking?

Use -s.

Augie Henriques

I compiled with -g3.

Andrew Thomas wrote:

Previously, Kevin O’Rourke wrote in qdn.public.qnx4:
I had a look at the assembly as it executed and the crash occurs in
the
‘push 00012084’ instruction which is executed immediately before ‘call
printf_’.

Not enough stack space? What happens if you turn on stack checking?
What happens if you increase the stack size?

As a further question: why can’t I see the local variables in main()
in
Watcom debugger. Other functions all have visible local variables but
main() just has an empty locals window.

I’m guessing: Did you compile main.c with -g1?

Andrew

According to the wcc documentation stack checking is on by default and
is disabled by -s.

I’m not getting any stack overflow warnings.
Kev.

Augie Henriques wrote:

“Kevin O’Rourke” <> kio@pcmail.nerc-bas.ac.uk> > wrote in message
news:> 3A9D3456.5C98502B@pcmail.nerc-bas.ac.uk> …
OK, how do I turn on stack checking?

Use -s.

“Kevin O’Rourke” <kio@pcmail.nerc-bas.ac.uk> wrote in message
news:3A9E1BF9.7D69E971@pcmail.nerc-bas.ac.uk

According to the wcc documentation stack checking is on by default and
is disabled by -s.

I’m not getting any stack overflow warnings.
Kev.

Augie Henriques wrote:

“Kevin O’Rourke” <> kio@pcmail.nerc-bas.ac.uk> > wrote in message
news:> 3A9D3456.5C98502B@pcmail.nerc-bas.ac.uk> …
OK, how do I turn on stack checking?

Use -s.

Can you post you compile/link options (makefile)?

Augie

Thanks to the people who responded on this one, I’ve run out of time
(end of contract) so I’m rolling the softare back to the version before
the problem started.

Kev.

Augie Henriques wrote:

“Kevin O’Rourke” <> kio@pcmail.nerc-bas.ac.uk> > wrote in message
news:> 3A9E1BF9.7D69E971@pcmail.nerc-bas.ac.uk> …
According to the wcc documentation stack checking is on by default and
is disabled by -s.

I’m not getting any stack overflow warnings.
Kev.

Augie Henriques wrote:

“Kevin O’Rourke” <> kio@pcmail.nerc-bas.ac.uk> > wrote in message
news:> 3A9D3456.5C98502B@pcmail.nerc-bas.ac.uk> …
OK, how do I turn on stack checking?

Use -s.

Can you post you compile/link options (makefile)?

Augie