Project

General

Profile

Bug #189

malloc ERROR

Added by Laura Torrente almost 12 years ago. Updated almost 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Parser/Interpreter
Target version:
Start date:
18 Jun 2012
Due date:
% Done:

100%

Estimated time:
Spent time:

Description

I get the following error

CoCoAInterpreter(13411) malloc: *** error for object 0x10156fcb8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

I hope it can be fixed soon.

Ciao, Laura

genus.cocoa5 (16.1 KB) genus.cocoa5 Main routine John Abbott, 19 Jun 2012 11:04
SSE.cocoa5 (5.21 KB) SSE.cocoa5 Auxiliary functions John Abbott, 19 Jun 2012 11:04

Related issues

Related to CoCoALib - Bug #190: Subtle ref count bug for poly rings (via CoeffEmbeddingHom)Closed2012-06-19

History

#1 Updated by John Abbott almost 12 years ago

  • Assignee set to John Abbott

Recompiled with MemPool debugging and linking with debug_new.o
The problem disappears... this may be enough to let Laura continue for a while.

JAA thinks we'll need valgrind or similar to sort this one out.
Hard to estimate how long it'll take.

#2 Updated by John Abbott almost 12 years ago

Laura's code works fine on my Linux VM.
However, Valgrind confirms that there is a memory access problem (seems to be a pointer/reference to a deleted ring). Will continue to investigate.

#3 Updated by John Abbott almost 12 years ago

The problem appears to be a RingHomValue in the interpreter which has a reference to a CoCoALib RingHom which has been destroyed. Unfortunately everything seems to have a ref count.

Attached are Laura's sources.

#4 Updated by Anna Maria Bigatti almost 12 years ago

  • Category set to Parser/Interpreter

I finally reduced the example: (quite a lot reduced ;-)
it seems due to having both a redefinition of the PolyRing and its CoeffEmbeddingHom

For i := 1 To 10 Do
  PrintLn i;
  QQX  := NewPolyRing(QQ, ["x"]);
  phi := CoeffEmbeddingHom(QQX);
EndFor;

#5 Updated by John Abbott almost 12 years ago

According to valgrind the following input is enough to do damage:

QQx ::= QQ[x];
phi := CoeffEmbeddingHom(QQx);
QQx ::= QQ[x];

Time to do some single stepping... sigh!

#6 Updated by John Abbott almost 12 years ago

Valgrind even complains about the following two lines!!

QQx ::= QQ[x];
phi := CoeffEmbeddingHom(QQx);

The error happens when the interpreter ends itself.

PS if I continue at this rate, in half an hour I'll have a 0 line program that causes a problem :-)

#7 Updated by John Abbott almost 12 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 50

If you add

phi := 0;

after the two lines in my previous post, then the problem goes away!

As far as I can tell, the problem arises inside the dtor for RuntimeEnvironment; unfortunately this is "invisible" code.

Even more unfortunately gdb does not work properly in my Linux VM :-(
[or it may just be a consequence of trying to debug invisible code]
So I shall have to try debugging on a real linux box... so I'm putting this issue "on hold" for a little while.

#8 Updated by John Abbott almost 12 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 50 to 100

The cause of the problem is a design bug in CoCoALib (see issue #190).
As a consequence I shall close this issue.

The recommended WORKAROUND is to assign an innocuous value (e.g. 0) to any variable used for holding a RINGHOM value when you have finished using it. Unfortunately, I fear the real bug will be time-consuming to kill. Apologies to all those who have to bespoil their code with the workaround.

#9 Updated by Anna Maria Bigatti almost 12 years ago

  • Target version set to CoCoA-5.0.3

Also available in: Atom PDF