Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add -gx to add stack smash code #1542

Merged
merged 1 commit into from Jan 24, 2013
Merged

add -gx to add stack smash code #1542

merged 1 commit into from Jan 24, 2013

Conversation

WalterBright
Copy link
Member

With -gx switch, adds code to smash the local variables upon function exit. Useful for flushing out heisenbugs.

A partial implementation of bug http://d.puremagic.com/issues/show_bug.cgi?id=9242

@alexrp
Copy link
Member

alexrp commented Jan 24, 2013

Maybe a different name? The term "stack smashing" is usually used in the context of the stack smashing protector that GCC and LLVM support: http://llvm.org/docs/LangRef.html#llvm-stackprotector-intrinsic (see also the ssp, sspreq, and sspstrong attributes in that document)

@WalterBright
Copy link
Member Author

I don't see the word "smash" in the linked page.

@alexrp
Copy link
Member

alexrp commented Jan 24, 2013

@yebblies
Copy link
Member

Why do you have this disabled for win64?

@yebblies
Copy link
Member

Sorry, I'm tried. What I meant to ask was - is this really equivalent to all of the other epilogs? And if so, could they be merged together instead of having a universal stack smash version and several target dependent versions?

@WalterBright
Copy link
Member Author

The other ones are optimal for different purposes, as the if statements set out. The win64 is different because the win64 api says it should be that way, see the supplied url.

@dnadlinger
Copy link
Member

I know I've used smashStack as function name in some code snippets I posted on the forums in the past, but when reading about »stack smashing« in connection with compilers, I think about the exploitation technique (as in the seminal »Smashing the Stack for Fun and Profit« paper) and related countermeasures, not a debugging helper.

So maybe »overwrite stack with garbage when returning from a function« or something along the lines would be a better description for a flag? A reference to »stack smashing code« would probably need further explanation in the (non-existent?) docs, unless you are building an exploit kit. ;)

@leandro-lucarella-sociomantic
Copy link
Contributor

On Thu, Jan 24, 2013 at 05:53:28AM -0800, David Nadlinger wrote:

I know I've used smashStack as function name in some code snippets I posted on the forums in the past, but still when reading about »stack smashing« in connection with compilers, I think about the exploitation technique (as in the seminal »Smashing the Stack for Fun and Profit« paper) and related countermeasures, not a debugging helper.

So maybe »overwrite stack with garbage when returning from a function« or something along the lines would be a better description for a flag? A reference to »stack smashing code« would probably need further explanation in the (non-existent?) docs, unless you are building an exploit kit. ;)

A similar technique is (optionally) used in the GC to debug memory
problems, and is called "memory stomping", so maybe "stack stomping"
could be used instead to maintain some consistency...

https://github.com/D-Programming-Language/druntime/blob/master/src/gc/gcx.d#L23

@WalterBright
Copy link
Member Author

stomping sounds good

WalterBright added a commit that referenced this pull request Jan 24, 2013
add -gx to add stack smash code
@WalterBright WalterBright merged commit b8d5ce9 into dlang:master Jan 24, 2013
@WalterBright WalterBright deleted the b29 branch January 24, 2013 23:28
@@ -47,7 +47,8 @@ void out_config_init(
int symdebug, // add symbolic debug information
// 1: D
// 2: fake it with C symbolic debug info
bool alwaysframe // always create standard function frame
bool alwaysframe, // always create standard function frame
bool stacksmash // add stack smashing code

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, it looks like you're using smashing in the code after all :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants