avatar
是不是cygwin问题?# Computation - 科学计算
s*b
1
cygwin下,运行a.out,显示segmentation fault, (core dumped),
possibly due to stack overflow(underflow?).
最大的数组 double 20000*16。其他的可以忽略不计。
winxp, 1.5G
avatar
c*e
2
unlikely

【在 s**b 的大作中提到】
: cygwin下,运行a.out,显示segmentation fault, (core dumped),
: possibly due to stack overflow(underflow?).
: 最大的数组 double 20000*16。其他的可以忽略不计。
: winxp, 1.5G

avatar
s*b
3
那是不是cygwin对这个支持不太好?

【在 c*******e 的大作中提到】
: unlikely
avatar
e*e
4
数组是局部变量?

【在 s**b 的大作中提到】
: cygwin下,运行a.out,显示segmentation fault, (core dumped),
: possibly due to stack overflow(underflow?).
: 最大的数组 double 20000*16。其他的可以忽略不计。
: winxp, 1.5G

avatar
s*b
5
全局变量

【在 e***e 的大作中提到】
: 数组是局部变量?
avatar
e*e
6
如果程序只有这个大的数组,当然有些简单访问,比如遍历累计之类的,
编译运行都没问题。

【在 s**b 的大作中提到】
: 全局变量
avatar
s*b
7
没看懂你说得和我问得有什么联系?

【在 e***e 的大作中提到】
: 如果程序只有这个大的数组,当然有些简单访问,比如遍历累计之类的,
: 编译运行都没问题。

avatar
f*a
8
how do you allocate memory for the data? It is not a limitation of CYGWIN.
If you are using malloc in C, notice there is a default stack size for each
program. You cannot claim for a size greater than the default size by
specifying a flag in gcc, which allows you to specify the stack size. Check
gcc manual.
However, I recommand to use the data structure "vector" in C++ and use g++.
vector gives the freedom for dynamic memory allocation.

【在 s**b 的大作中提到】
: cygwin下,运行a.out,显示segmentation fault, (core dumped),
: possibly due to stack overflow(underflow?).
: 最大的数组 double 20000*16。其他的可以忽略不计。
: winxp, 1.5G

avatar
s*b
9
I just use an array x[size][size], where size is some big number, but
should not exceed my physical memory. The same code cna run under linux
without any problem.

each
Check
.

【在 f*******a 的大作中提到】
: how do you allocate memory for the data? It is not a limitation of CYGWIN.
: If you are using malloc in C, notice there is a default stack size for each
: program. You cannot claim for a size greater than the default size by
: specifying a flag in gcc, which allows you to specify the stack size. Check
: gcc manual.
: However, I recommand to use the data structure "vector" in C++ and use g++.
: vector gives the freedom for dynamic memory allocation.

avatar
f*a
10
You solution is not sufficient. For instance, if your machine has 1G of
memory, the OS will not allow you to use all of them.
when you run a program, a stack with a finite size is created automatically.
if x[size][size] exceeds this default size of the stack, you will receive
the notorious segmentation fault. (This default stack size might vary among
platforms, which explains why your code runs in linux.) One way to work
around this problem is to specify a flag to gcc when you compile the proble
avatar
s*b
11
under cygwin, i try to set stacksize, but it always says
something like stacksize cannot be changed.
I have uninstalled cygwin, so I cannnot re-run the code.

automatically.
among
problem

【在 f*******a 的大作中提到】
: You solution is not sufficient. For instance, if your machine has 1G of
: memory, the OS will not allow you to use all of them.
: when you run a program, a stack with a finite size is created automatically.
: if x[size][size] exceeds this default size of the stack, you will receive
: the notorious segmentation fault. (This default stack size might vary among
: platforms, which explains why your code runs in linux.) One way to work
: around this problem is to specify a flag to gcc when you compile the proble

avatar
f*a
12
i used
g++ -Wl,--stack,10000000 -g funnyhaha.cpp
avatar
s*b
13
i use similar parameters and have the mentioned error.
I can only change stacksize in a range, ohterwise it will give
some kind of warning by cygwin.
not sure the detail.

【在 f*******a 的大作中提到】
: i used
: g++ -Wl,--stack,10000000 -g funnyhaha.cpp

avatar
f*a
14
you cannot allocate all the memory by this static memory allocation. Use
malloc() for dynamic memory allocation. This will give you much more space
than what you can achieve with specifying stack size.

【在 s**b 的大作中提到】
: i use similar parameters and have the mentioned error.
: I can only change stacksize in a range, ohterwise it will give
: some kind of warning by cygwin.
: not sure the detail.

avatar
s*b
15
you mean in the code?
anyway, it can run under linux but not cygwin,
so i want to know if there is anyway to correct this problem.

【在 f*******a 的大作中提到】
: you cannot allocate all the memory by this static memory allocation. Use
: malloc() for dynamic memory allocation. This will give you much more space
: than what you can achieve with specifying stack size.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。