El día sábado, marzo 16, 2019 a las 11:50:48a. m. +0000, Tom Hughes escribió:

> On 16/03/2019 11:42, Matthias Apitz wrote:
> > El día sábado, marzo 16, 2019 a las 09:23:06a. m. +0100, Matthias Apitz 
> > escribió:
> > 
> >>> What is the value of MAX_FSTAB_ROWS ?
> >>
> >> #define MAX_FSTAB_ROWS 3000
> > 
> > I set a gdb breakpoint at the entry of FstabInit(). The size of the
> > array is:
> > 
> > (gdb) p sizeof(t_sik_fstab)
> > $4 = 950
> > (gdb) p sizeof(myFSTABrows)
> > $5 = 2850000
> > 
> > and as well I can not see anything unusual while stepping through the
> > init sequence of the function.
> 
> That's nearly 3Mbytes that you are creating on the stack
> which is quite a lot...
> 
> More importantly it is more than the default value that
> valgrind uses for --max-stackframe so it is likely to lead
> to confusion - do you get a warning about a stack switch
> being assumed before those other messages?
> 
> Try using --max-stackframe=4000000 or something to specify
> a larger maximum stack frame size and see if that helps.

It says at the start when  I set '--main-stacksize=640000000':

==5868== Memcheck, a memory error detector
==5868== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==5868== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==5868== Command: /opt/lib/sisis/opserver/bin/OPServer -p 4711
==5868==

16.03.2019 09:17:15.772  OPServer <5868> : started at : 16.03.2019  09:17:15

==5868== Warning: client switching stacks?  SP change: 0xffefff3e8 --> 
0xffed47690
==5868==          to suppress, use: --max-stackframe=2850136 or greater
==5868== Invalid write of size 4
==5868==    at 0x9DE90EF: FstabInit (BKFstab.c:2131)
==5868==    by 0x6BFF1E8: OpsInitDatabase (SRVServerInit.c:1299)
==5868==    by 0x413B48: SlnpInitDaemon (OPDaemon.c:738)
==5868==    by 0x413657: main (OPDaemon.c:272)
==5868==  Address 0xffed476bc is on thread 1's stack
==5868==  in frame #0, created by FstabInit (BKFstab.c:2131)


Ahh, it's requesting to higher '--max-stackframe'. The '--main-stacksize'
is per default 8M and big enough, but '--max-stackframe' is per default
only 2000000.  I set it to 8000000 and with this the warning above and the
false positive about bad reads in FstabInit() disappeared. 

Thanks for the hint and I will think in rewrite this using malloc(3C).
Lesson learned.

        matthias

-- 
Matthias Apitz, ✉ g...@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to