| Deutsch English Français Italiano |
|
<vme199$4g29$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Thomas Koenig <tkoenig@netcologne.de> Newsgroups: comp.arch Subject: Re: Segments Date: Fri, 17 Jan 2025 16:42:17 -0000 (UTC) Organization: A noiseless patient Spider Lines: 53 Message-ID: <vme199$4g29$1@dont-email.me> References: <vdlgl9$3kq50$2@dont-email.me> <vlgreu$1lsr9$1@dont-email.me> <vlhjtm$1qrs5$1@dont-email.me> <bdZeP.23664$Hfb1.16566@fx46.iad> <vlj1pg$25p0e$1@dont-email.me> <87cygo97dl.fsf@nosuchdomain.example.com> <vm7mvi$2rr87$1@dont-email.me> <20250115140026.00003f4f@yahoo.com> <vm8t42$3221i$1@dont-email.me> <20250115222824.000034d6@yahoo.com> <vm97j3$342b3$1@dont-email.me> <vmar0d$3g078$1@dont-email.me> <20250116143532.00002117@yahoo.com> <vmavsb$3gpni$1@dont-email.me> <vmbd4n$3v6su$3@paganini.bofh.team> <vmbsvr$3lpar$1@dont-email.me> Injection-Date: Fri, 17 Jan 2025 17:42:18 +0100 (CET) Injection-Info: dont-email.me; posting-host="01180cae09c5abdeb96da5707b048ecc"; logging-data="147529"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8TjPx4nkEjX33N2H4uDFfd6FYIcOsmCs=" User-Agent: slrn/1.0.3 (Linux) Cancel-Lock: sha1:wpyDu8TQ5ys5qI/BWXRSgg8BQSE= David Brown <david.brown@hesbynett.no> schrieb: > On 16/01/2025 17:46, Waldek Hebisch wrote: >> David Brown <david.brown@hesbynett.no> wrote: >>> On 16/01/2025 13:35, Michael S wrote: >>>> On Thu, 16 Jan 2025 12:36:45 +0100 >>>> David Brown <david.brown@hesbynett.no> wrote: >>>> >>>>> On 15/01/2025 21:59, Thomas Koenig wrote: >>>>>> Michael S <already5chosen@yahoo.com> schrieb: >>>>>>> On Wed, 15 Jan 2025 18:00:34 -0000 (UTC) >>>>>>> Thomas Koenig <tkoenig@netcologne.de> wrote: >>>>>>> >> >>>> As you can guess, in kernel drivers VLA are unwelcome. >>> >>> I can imagine that they are - but I really don't understand why. I've >>> never understood why people think there is something "dangerous" about >>> VLAs, or why they think using heap allocations is somehow "safer". >> >> VLA normally allocate on the stack. Which at first glance look >> great. But once one realize how small are stacks in modern >> systems (compared to whole memory), this no longer looks good. >> Basically, to use VLA one needs rather small bound on maximal >> size of array. > > Sure. > >> Given such bound always allocating maximal >> size is simpler. Without _small_ bound on size heap is >> safer, as it is desined to handle also big allocations. > > You don't allocate anything in a VLA without knowing the bounds and > being sure it is appropriate to put on the stack. In general, that is a hard thing to know - there is no standard way to enquire the size of the stack, how much you have already used, how deep you are going to recurse, or how much stack a function will use. These may be points that you are looking at for your embedded work, but the average programmer does not. An example, Fortran-specific: Fortran 2018 made all procedures recursive by default. This means that some Fortran codes will start crashing because of stack overruns when this is implemented :-( > You don't allocate > anything on the heap without knowing the bounds and being sure it is > appropriate. There's no fundamental difference - it's just the cut-off > point that is different. What would you recommend as a limt? (See fmax-stack-var-size=N in gfortran).