View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0021550FPCCompilerpublic2012-03-25 17:522012-05-10 17:50
ReporterDenis Golovan 
Assigned ToSven Barth 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version2.7.1Product Buildsvn 20584 
Target VersionFixed in Version2.7.1 
Summary0021550: Generics classes + static fields crash compiler
DescriptionHi

See a small example attached.
A compiler just crashes with following stack in console:

EAccessViolation: Access violation
  $080499D5
  $0808D780 TFPHASHOBJECT__GETNAME, line 1696 of cclasses.pas
  $081E96DD STRING_EVALUATE, line 284 of dbgstabs.pas
  $081ED564 TDEBUGINFOSTABS__SYM_STABSTR_EVALUATE, line 1189 of dbgstabs.pas
  $081ED8FC TDEBUGINFOSTABS__APPENDSYM_STATICVAR, line 1258 of dbgstabs.pas
  $080EE9EA TDEBUGINFO__APPENDSYM, line 397 of dbgbase.pas
  $081EE9BB TDEBUGINFOSTABS__INSERTTYPEINFO, line 1535 of dbgstabs.pas
  $0819CCAE PROC_UNIT, line 1427 of pmodules.pas
  $08186E1B COMPILE, line 395 of parser.pas
  $081933B0 TPPUMODULE__LOADPPU, line 1654 of fppu.pas
  $0819B77B LOADUNITS, line 842 of pmodules.pas
  $0819C447 PROC_UNIT, line 1212 of pmodules.pas
  $08186E

That's in fact a regression.
Previously the code was working.
Tagsgenerics
FPCOldBugId
Fixed in Revision21270
Attached Files? file icon project1.lpr [^] (282 bytes) 2012-03-25 17:52

- Relationships
related to 0021567closedMaxim Ganetsky Lazarus Generics classes + static fields crash build 
has duplicate 0021654resolvedSven Barth FPC "Fatal: Compilation aborted" on Static field at Generics 

-  Notes
(0058052)
Denis Golovan (reporter)
2012-03-26 15:18

Same problem occurs when I try to use "class var" syntax instead of "static" and "object" instead of "class".
(0058056)
Denis Golovan (reporter)
2012-03-26 15:57

Please close this bug.
After additional investigation http://bugs.freepascal.org/view.php?id=21567 [^] was created.
(0058078)
Jonas Maebe (manager)
2012-03-26 20:58

The backtrace you show is from the compiler, not from Lazarus.
(0058079)
Denis Golovan (reporter)
2012-03-26 21:01

I think you know better :)
The exception is thrown when compiling under Lazarus.
(0058099)
Sven Barth (manager)
2012-03-27 09:11

But Lazarus invokes the compiler for compilation. So it's basically no difference whether you compile by hand or through Lazarus.

Regards,
Sven
(0058122)
Denis Golovan (reporter)
2012-03-27 18:07

Right.
I've made the wrong conclusion.
It's compiler's fault. Tested under FPC svn rev. 20584 under Linux 32 bit.

$fpc -gl project1.lpr
Free Pascal Compiler version 2.7.1 [2012/03/25] for i386
Copyright (c) 1993-2011 by Florian Klaempfl and others
Fatal: Compilation aborted
An unhandled exception occurred at $080499D5:
EAccessViolation: Access violation
  $080499D5
  $0808D780 TFPHASHOBJECT__GETNAME, line 1696 of cclasses.pas
  $081E96DD STRING_EVALUATE, line 284 of dbgstabs.pas
  $081ED564 TDEBUGINFOSTABS__SYM_STABSTR_EVALUATE, line 1189 of dbgstabs.pas
  $081ED8FC TDEBUGINFOSTABS__APPENDSYM_STATICVAR, line 1258 of dbgstabs.pas
  $080EE9EA TDEBUGINFO__APPENDSYM, line 397 of dbgbase.pas
  $081EE9DD TDEBUGINFOSTABS__INSERTTYPEINFO, line 1537 of dbgstabs.pas
  $0819F31C PROC_PROGRAM, line 2421 of pmodules.pas
  $08186E5A COMPILE, line 403 of parser.pas
  $08067175 COMPILE, line 252 of compiler.pas

Error: /usr/local/bin/ppc386 returned an error exitcode

Changing to Dwarf3 debug format make it compile successfully.

$fpc -gw3 project1.lpr
Free Pascal Compiler version 2.7.1 [2012/03/25] for i386
Copyright (c) 1993-2011 by Florian Klaempfl and others
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?

P.S. What made me think it's Lazarus fault is "fpc project1.lpr" completed successfully.
(0058586)
Denis Golovan (reporter)
2012-04-14 15:19

heaptrc does not work with Dwarf3 debug format :(
Guys, any progress on this so far?
(0059381)
Sven Barth (manager)
2012-05-08 09:32

Please test and close if okay.

Regards,
Sven
(0059415)
Denis Golovan (reporter)
2012-05-08 21:56

@Sven Barth
Unfortunately I cannot confirm your fix. Still the same error.

$ fpc -gl project1.lpr
Free Pascal Compiler version 2.7.1 [2012/05/08] for i386
Copyright (c) 1993-2012 by Florian Klaempfl and others
Fatal: Compilation aborted
An unhandled exception occurred at $080499D5:
EAccessViolation: Access violation
  $080499D5
  $0808D50A TFPHASHOBJECT__GETNAME, line 1731 of cclasses.pas
  $0822CA9D STRING_EVALUATE, line 306 of dbgstabs.pas
  $082301F4 TDEBUGINFOSTABS__SYM_STABSTR_EVALUATE, line 1132 of dbgstabs.pas
  $082309AA TDEBUGINFOSTABS__APPENDSYM_STATICVAR, line 1223 of dbgstabs.pas
  $080F16BA TDEBUGINFO__APPENDSYM, line 397 of dbgbase.pas
  $08232C1D TDEBUGINFOSTABS__INSERTTYPEINFO, line 1632 of dbgstabs.pas
  $081B054C PROC_PROGRAM, line 2102 of pmodules.pas
  $08198F62 COMPILE, line 403 of parser.pas
  $08067835 COMPILE, line 255 of compiler.pas

Error: /usr/local/bin/ppc386 returned an error exitcode
(0059436)
Sven Barth (manager)
2012-05-09 14:35

Yes, you are right. My failure. I didn't see that you use debug information.

Regards,
Sven
(0059442)
Jonas Maebe (manager)
2012-05-09 18:21

I think the patch you reverted in r21264 could have stayed, I doubt it is related to this crash.

To solve this problem, you probably just have to add a check for generics in TDebugInfo.appenddef (for procdef) and TDebugInfo.appendsym (for everything else), both in dbgbase.pas. Simply do not write anything in case of a generic definition and everything will probably be fine for all debug formats.
(0059458)
Sven Barth (manager)
2012-05-10 09:35

> I think the patch you reverted in r21264 could have stayed, I doubt it is related to this crash.

Trust me, I know why I reverted that... It had nothing todo with one of the two static related errors to begin with, but it the bug it introduced appeared if you removed the specialization in your example, because the compiler then reached the linking stage which triggered the bug. I'll need to find a better solution to avoid the generation of the unnecessary generic static symbol.

> To solve this problem, you probably just have to add a check for generics in TDebugInfo.appenddef (for procdef) and TDebugInfo.appendsym (for everything else), both in dbgbase.pas. Simply do not write anything in case of a generic definition and everything will probably be fine for all debug formats.

No, the problem was different: it basically was accesing objects that were already freed, because the ownership of the static symbol got a bit mixed up.

Summa summarum: please test and close if okay.

Regards,
Sven
(0059471)
Denis Golovan (reporter)
2012-05-10 17:50

Super thanks!
Now it works.

- Issue History
Date Modified Username Field Change
2012-03-25 17:52 Denis Golovan New Issue
2012-03-25 17:52 Denis Golovan File Added: project1.lpr
2012-03-26 15:18 Denis Golovan Note Added: 0058052
2012-03-26 15:57 Denis Golovan Note Added: 0058056
2012-03-26 20:57 Jonas Maebe Relationship added related to 0021567
2012-03-26 20:58 Jonas Maebe Note Added: 0058078
2012-03-26 21:01 Denis Golovan Note Added: 0058079
2012-03-27 09:11 Sven Barth Note Added: 0058099
2012-03-27 09:14 Sven Barth Tag Attached: generics
2012-03-27 18:07 Denis Golovan Note Added: 0058122
2012-04-14 15:19 Denis Golovan Note Added: 0058586
2012-05-08 09:32 Sven Barth Fixed in Revision => 21251
2012-05-08 09:32 Sven Barth Status new => resolved
2012-05-08 09:32 Sven Barth Fixed in Version => 2.7.1
2012-05-08 09:32 Sven Barth Resolution open => fixed
2012-05-08 09:32 Sven Barth Assigned To => Sven Barth
2012-05-08 09:32 Sven Barth Note Added: 0059381
2012-05-08 09:33 Sven Barth Relationship added has duplicate 0021654
2012-05-08 21:56 Denis Golovan Status resolved => feedback
2012-05-08 21:56 Denis Golovan Resolution fixed => reopened
2012-05-08 21:56 Denis Golovan Note Added: 0059415
2012-05-09 14:35 Sven Barth Note Added: 0059436
2012-05-09 14:35 Sven Barth Status feedback => assigned
2012-05-09 18:21 Jonas Maebe Note Added: 0059442
2012-05-10 09:35 Sven Barth Fixed in Revision 21251 => 21270
2012-05-10 09:35 Sven Barth Status assigned => resolved
2012-05-10 09:35 Sven Barth Resolution reopened => fixed
2012-05-10 09:35 Sven Barth Note Added: 0059458
2012-05-10 17:50 Denis Golovan Status resolved => closed
2012-05-10 17:50 Denis Golovan Note Added: 0059471



MantisBT 1.2.12[^]
Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker