【发布时间】:2015-03-03 22:51:43
【问题描述】:
我目前在为我的编程课程构建的程序中遇到访问冲突的几个问题。它是用 pascal(课程使用的语言)构建的,并使用 Lazarus IDE(类似于 Delphi,但开放)。
据我所知,当您尝试使用或解决无效的内存位置时,会发生访问冲突或 SIGSEGV 错误。我经历过很多这样的事情,特别是当我没有声明动态数组的长度时。
现在看来我遇到了字符串问题。 (或者我可能会使用多维数组)。
我将只粘贴 SIGSEGV 指向的过程,但上下文是:
我有一个整数数组和一个包含它的幂集 (subconjuntos) 的多维数组,弹出错误的函数(如下所述)用于将此幂集打印为文本框(由本地索引):
procedure writeSub(local: TEdit);
var
i, j: integer;
begin
for i:= 0 to High(subconjuntos)+1 do
if Length(subconjuntos[i])>1 then
begin
local.Text:=local.Text+'[';
for j:=0 to High(subconjuntos[i])+1 do local.Text:=local.Text+'('+IntToStr(subconjuntos[i][j])+') ';
local.Text:=local.Text+'] ';
end
else local.Text:=local.Text+'['+IntToStr(subconjuntos[i][0])+'] '; {this is where I'm having the SIGSEG, the program wont compile if I don't reference it without the double brackets}
end;
知道为什么它会抛出 SIGSEGV 吗?
【问题讨论】:
-
我删除了 Delphi 标签,因为这个问题不适用于 Delphi。 Delphi 不抛出 SIGSEGV,不使用 FPC,因此与此问题无关。在你的问题标题中包含标签信息也是不合适的;标签系统在这里工作得非常好,可以对问题进行分类并将它们提供给熟悉这些标签的人。
标签: arrays lazarus freepascal segmentation-fault