Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 26, 2013, 12:32 AM   #1
Sydde
macrumors 68000
 
Sydde's Avatar
 
Join Date: Aug 2009
llvm question: big automatics

Some while ago, there was a thread here wherein the author could not figure out why a routine ran fine on the main thread but crashed on any other thread – turned out a huge array, like 2Mb, was being allocated, spilling out all over the local stack space.

So, it occurred to me, could one set the compiler back-end (llvm) to observe excessive stack consumption and convert it to temporary heap allocation? Or is this what it already does? Obviously, if it can handle ARC, this would be even easier (of course, any additional returns would have to have matching free()s), the only real difference is that the local variable would be accessed with a pointer, though the source syntax would be identical.

What I imagine is that with such an option enabled, a main thread routine allocating a big array would have a slightly greater chance of failing (due to a malloc() error), while a secondary thread might fail in an orderly fashion rather than assuredly crashing – in either case, a returned NULL pointer would result in a transparent exception throw added in to the object code.

So, my question is, assuming this is not being done, would it be a good idea? I, personally, regard stack space as sort of valuable, so I would allocate the heap block as a matter of course, but would it be wise to obscure this kind of thing from the programmer? Are the old-school, machine-aware habits just becoming passé?
__________________
You got to be a spirit. You can't be no ghost.
Sydde is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:00 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC