l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
September 2: Social Gathering
Next Installfest:
Sat. Sept. 27, 10am-6pm
Latest News:
Aug. 30: September Installfest scheduled
Page last updated:
2006 Feb 08 12:45
Events
 Meetings
 Installfests
 Demos
 Photos
Services
 Library
 LERT
 Jobs
 Documents
Interact
 Mailing Lists
 - Search
 - Archives
 Chat
About Us
 Members
 Projects
 Testimonials
 Call for Speakers
 Why Not MS?
 Finances
 Sponsors

^Home
?Search
?News & RSS
?Calendar
@Contact Us
$Buy Stuff
=Printable


The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] cygwin - segfault on array allocation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] cygwin - segfault on array allocation



On Wed 08 Feb 06, 11:29 AM, Micah J. Cowan <micah@cowan.name> said:
> On Wed, Feb 08, 2006 at 12:12:19PM -0500, Peter Jay Salzman wrote:
> > i'm finding that cygwin segfaults on a very simple program:
> > 
> >    #include <iostream>
> >    using std::cout;
> >    using std::endl;
> >    // 50760 is the last
> > 
> >    int main( int argc, char *argv[] )
> >    {
> >       const long int N = strtol(argv[1], (char **)0, 0);
> >       double a[N], b[N], c[N], d[N], ans[N];
> > 
> >       return 0;
> >    }
> 
> First: note that the above is not portable code. C++ does not support
> variable-length arrays (that is, the bracketed expression must be a
> constant). As long as you're constraining yourself to g++, though, or
> other ones that support this extension, you're fine. (VLAs /are/
> supported in the current version of the ISO C Standard, BTW).
 
How does one gain this kind of knowledge at fingertips?

(snip)

> >    $ gdb arg.exe
> >    GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)
> >    (gdb) set args 50761
> >    (gdb) break 1
> >    Breakpoint 1 at 0x401050: file arg.cc, line 1.
> >    (gdb) run
> >    Starting program: /cygdrive/c/Documents and
> >    Settings/psalzman/home/tests/args/arg.exe 50761
> > 
> >    Breakpoint 1, main (argc=2, argv=0x4c2b90) at arg.cc:7
> >    7       {
> >    (gdb) n
> > 
> >    Program received signal SIGSEGV, Segmentation fault.
> >    0x610ae938 in pthread_key_create () from /usr/bin/cygwin1.dll
> >    (gdb)
> > 
> > which is odd; I don't believe this line number.
> 
> What line number? It didn't break at 7, it broke after you "stepped"
> after 7, which means you don't necessarily know where it broke. I
> usually let segfaulting programs dump core, and then use gdb to examine
> where it was when it got the signal. I don't think you'll get very
> useful information that way for this example, however.

Yeah, did that.  Didn't give any line number associated with the signal.  It
actually said there were corrupted frames on the stack frame.

Pete
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

CD Burns Wanted!

LUGOD: Linux Users' Group of Davis
1105 Kennedy Place, Suite 1, Davis, CA 95616
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
nerdbooks.com
For numerous book donations.