public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Greetings...
@ 2000-09-28 16:20 Shelby Cain
  2000-10-03 12:47 ` Problems in using gdb to catch the seg fault (was: Re: Greetings...) Andreas Eibach
  0 siblings, 1 reply; 3+ messages in thread
From: Shelby Cain @ 2000-09-28 16:20 UTC (permalink / raw)
  To: cygwin

Hello all -- I'm new to the list and I have a question that I'm sure has
been asked many times before.  I'm used to using tools like gcc, gdb, make,
etc in a mixed environment of Solaris and Linux.

My problem is taking a simple program like so:

int main()
{
    char * foo = 0;
    crashme(foo);
}

int crashme(char * cp);
{
    strcpy(cp, "KABOOM!!");
}

and compiling and linking it via -g using cygwin produces an executable that
does not produce a core file when it crashes.  One might suggest that
running it via gdb (ie: gdb crashme.exe) will allow me to catch the
offending statement... however I would really prefer a core file to work
with as I don't have to "recreate" the situation in order to see what is
going on.

Even when I use gdb to catch the seg fault... the stack window isn't
providing me with any useful information.  When I open up the gdb console
and try "backtrace" I get something to the effect of:

"Error: #0  0x61070850 in _size_of_stack_reserve__ ()
Cannot access memory at address 0x2000000"

Normally I would expect the backtrace to produce something meaningful like:

#0  0xef6a4644 in strcpy () from /usr/lib/libc.so.1
#1  0x10598 in crashme (cp=0x0) at test.c:9
#2  0x10574 in main () at test.c:4

Could anyone explain this to me outright or point me towards a FAQ?

Regards,

Shelby Cain


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Problems in using gdb to catch the seg fault (was: Re: Greetings...)
  2000-09-28 16:20 Greetings Shelby Cain
@ 2000-10-03 12:47 ` Andreas Eibach
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Eibach @ 2000-10-03 12:47 UTC (permalink / raw)
  To: Shelby Cain; +Cc: cygwin

> I'm used to using tools like gcc, gdb, make,
> etc in a mixed environment of Solaris and Linux.
>
> My problem is taking a simple program like so:


[1]> int main()
[2]> {
[3]>     char * foo = 0;
[4]>     crashme(foo);
[5]> }
[6]>
[7]> int crashme(char * cp);
[8]> {
[9]>     strcpy(cp, "KABOOM!!");
[10]> }
[11]>

AARGHH...
Well I'm no C professional, but I can say there's something odd about your
code.
To put this another way: I've _never_ _seen_ _this_!

You can be quite happy that this is not considered a crime you could be
arrested for
*grin*
Why do people need to crash programs _intentionally_ - just for fun?
OH BOY...;)

I've added line numbers to be able to better refer to specific lines.

Rule Of Thumb:
 - NEVER program any function without a prototype!!

- Line [7] IS a *prototype*, but where's the *function*??

 [7]> int crashme(char * cp);

You MUST  NOT  set a semicolon if you want to _code_ the function.
So:
 void function(char * parm)  /* no semicolon!! */
 {

 }

And WHY do you define the function as INT if you don't want a return value??
This can't be reasonable.
If you insist to use an INT function you must call  it this way:

  int dummy;

 dummy = crashme(foo);

 And crashme() must contain return <something>;
 So do declare the function as VOID if you don't want return values!

-----

So use this code if you want to "debug" your "program":

/* _prototype_ of function = DECLARATION */

void crashme (char *);

 int main(void)
 {
    char * foo = 0;
    crashme(foo);
 }

/* _implementation_ of function = DEFINITION, don't confuse these! */

void crashme(char * cp) /* no semicolon!! */
 {
    strcpy(cp, "KABOOM!!");
 }

--------

Let's test it now.
I know it still _crashes_ now (that's what you wanted, eh? :P )
because if the program  was written correctly,
main() had got a char[] vector and not foo would've passed to
crashme(), but &foo (the address).

Andreas

NB: I got a correctly dumped core now.




--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Greetings.
@ 2018-10-17 20:09 Mr. Kofi Adomakoh
  0 siblings, 0 replies; 3+ messages in thread
From: Mr. Kofi Adomakoh @ 2018-10-17 20:09 UTC (permalink / raw)
  To: cygwin

 - This mail is in HTML. Some elements may be ommited in plain text. -

Good day,


Firstly, I apologize for sending you this sensitive information via e-mail instead of a Certified/Post-mail. It is understandable that you might be a little bit apprehensive because you do not know me, But I have a lucrative business offer of mutual interest i sent you before, Hope you got my last email.


Mr. Kofi Adomakoh.


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-17 20:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-28 16:20 Greetings Shelby Cain
2000-10-03 12:47 ` Problems in using gdb to catch the seg fault (was: Re: Greetings...) Andreas Eibach
2018-10-17 20:09 Greetings Mr. Kofi Adomakoh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).