Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2014-03

Heaptrace + cwstring cause SIGSEGV at the end

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Petr Kristan

Hi.

I use heaptrc and cwstring units in Linux.
If memoryleak occurs and program ends, then i get SIGSEGV in cwstring.pp:481 (iconv call) because cwstring unit is finalized before heaptrc.

#1 iconv(<optimized out>, 0x7fffffffd738, 0x7fffffffd760, 0x7fffffffd730, 0x7fffffffd748) at iconv.c:53 #2 ANSI2WIDEMOVE(0x7fffef7cf038 '/home/petr/obis4/bin/obis-linux', 65001, 0x7fffee687dd8 '', 31) at ../unix/cwstring.pp:481 #3 fpc_ansistr_to_widechararray(0x7fffffffd830 #43472#63484#32767, 255, 0x7fffef7cf038 '/home/petr/obis4/bin/obis-linux') at ../inc/ustrings.inc:820 #4 ASSIGN({}, 0x7fffef7cf038 '/home/petr/obis4/bin/obis-linux') at ../inc/file.inc:58 #5 ASSIGN({}, '/home/petr/obis4/bin/obis-linux') at ../inc/file.inc:71 #6 OPENEXEFILE({F = {}, SIZE = 0, ISOPEN = false, NSECTS = 0, SECHDROFS = 0, SECSTROFS = 0, PROCESSADDRESS = 0, FUNCTIONRELATIVE = false, IMGOFFSET = 0, FILENAME = ... #7 OPENDWARF(0x4633a2) at ../inc/lnfodwrf.pp:152
#8 GETLINEINFO(4600738, '', '', 0) at ../inc/lnfodwrf.pp:734 #9 DWARFBACKTRACESTR(0x4633a2) at ../inc/lnfodwrf.pp:767 #10 CALL_STACK(0x7fffeea43d00, {}) at ../inc/heaptrc.pp:307 #11 DUMPHEAP at ../inc/heaptrc.pp:1233
#12 TRACEEXIT at ../inc/heaptrc.pp:1486
#13 HEAPTRC_$$_finalize at :1615
#14 FINALIZEUNITS at ../inc/system.inc:907
#15 INTERNALEXIT at ../inc/system.inc:960
#16 DO_EXIT at ../inc/system.inc:1024
#17 :63

Heaptrace is switched on by -gl fpc option.

obis.lpr:
uses
cthreads, cwstring
...

fpc 2.7.1 and lazarus 1.3

Exists some solution for this problem?

Thanks
Petr

Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401 Czech Republic (Eastern Europe) fax: +420 461101481

Reply by email

Jonas Maebe
to Petr Kristan
Petr Kristan wrote
If memoryleak occurs and program ends, then i get SIGSEGV in cwstring.pp:481 (iconv call) because cwstring unit is finalized before heaptrc.

If you use -gh, then heaptrc will be the first unit of the uses clause and will be finalized after any manually added unit.

Heaptrace is switched on by -gl fpc option.

-gl switches on lineinfo, not heaptrc.

Jonas

Reply by email

Sergei Gorelkin
to Jonas Maebe

10.03.2014 19:40, Jonas Maebe пишет:

Show quoted text 10 lines
On 10 Mar 2014, at 16:13, Petr Kristan wrote: > If memoryleak occurs and program ends, then i get SIGSEGV in cwstring.pp:481 (iconv call) > because cwstring unit is finalized before heaptrc. If you use -gh, then heaptrc will be the first unit of the uses clause and will be finalized after any manually added unit.

That's exactly the issue. Being finalized last, heaptrc must not do anything that depends on functionality from other units, except system, but it does due to recent Unicode-related changes (indirectly, see the stack trace).

Even further, in case of error RTL tries to print a backtrace right after finalizing all units (see InternalExit procedure in system.inc), which can lead to similar problems.

Regards,
Sergei

Reply by email

Jonas Maebe
to Sergei Gorelkin
Sergei Gorelkin wrote 14 lines
10.03.2014 19:40, Jonas Maebe пишет: > > On 10 Mar 2014, at 16:13, Petr Kristan wrote: > >> If memoryleak occurs and program ends, then i get SIGSEGV in cwstring.pp:481 (iconv call) >> because cwstring unit is finalized before heaptrc. > > > If you use -gh, then heaptrc will be the first unit of the uses clause and will be finalized after > any manually added unit. > That's exactly the issue. Being finalized last, heaptrc must not do anything that depends on functionality from other units, except system, but it does due to recent Unicode-related changes (indirectly, see the stack trace). Even further, in case of error RTL tries to print a backtrace right after finalizing all units (see InternalExit procedure in system.inc), which can lead to similar problems.

You're right. We should probably reinstally the previous (default) widestring manager in the finalization section of cwstring).

Jonas

Reply by email