Skip to content

Conversation

@schveiguy
Copy link
Member

Fixes memory corruption introduced when (ironically) trying to support dip25: #4746

Instead of the original mechanism (which was to slice the buffer with an enum), I just added padding when in unittest mode to make sure the size is the same. Very hard to unittest this, since unittests actually change the layout in the original! I'm open to suggestions.

ping @WalterBright

@dlang-bot
Copy link
Contributor

dlang-bot commented Dec 15, 2017

Thanks for your pull request, @schveiguy!

Bugzilla references

Auto-close Bugzilla Description
18084 [REG2.072] tempCString buffer size is unittest-versioned

@schveiguy
Copy link
Member Author

Crap, I didn't target stable.

@schveiguy schveiguy closed this Dec 15, 2017
@wilzbach
Copy link
Contributor

You can change the branch when you click on edit. Top right

@schveiguy schveiguy reopened this Dec 15, 2017
@schveiguy
Copy link
Member Author

OK, I'll try it. Will it rebase automatically?

@schveiguy schveiguy changed the base branch from master to stable December 15, 2017 21:27
@wilzbach
Copy link
Contributor

OK, I'll try it. Will it rebase automatically?

Nope. Try:

git rebase --onto upstream/stable

@schveiguy
Copy link
Member Author

OK, I think I got it. This may cause problems when merging back to master, because this whole file was refactored.

@schveiguy schveiguy changed the title Fix issue 18084 - tempCString type should not change layout when used in unittests. Fix issue 18084 - tempCString type should not change size when used in unittests. Dec 15, 2017
@schveiguy schveiguy added the Review:Trivial typos, formatting, comments label Dec 19, 2017
@schveiguy
Copy link
Member Author

ping, this is pretty trivial, and is a memory corruption bug. We should fix it ASAP.

@MartinNowak @WalterBright @andralex @klickverbot

@schveiguy
Copy link
Member Author

Ah nuts. So the master version that I first targeted got merged into stable 😆

So I will rework this again back the way it was. At least there won't be any merge conflicts!

@schveiguy
Copy link
Member Author

OK, that should do it.

@wilzbach the problem was that master had refactored the file, so when I retargeted stable, there were conflicts when trying to rebase. Then the master branch was merged into stable, so there were conflicts again! In any case, it should be good now (I hope).

@andralex
Copy link
Member

@MartinNowak target to stable?

@jacob-carlborg
Copy link
Contributor

jacob-carlborg commented Dec 20, 2017

Instead of the original mechanism (which was to slice the buffer with an enum), I just added padding when in unittest mode to make sure the size is the same. Very hard to unittest this, since unittests actually change the layout in the original! I'm open to suggestions.

@schveiguy can you instantiate TempCStringBuffer with a larger type than the default to get the same behavior without having to change the size in unit test mode?

@wilzbach
Copy link
Contributor

target to stable?

It's already targeted at stable:

image

@wilzbach the problem was that master had refactored the file, so when I retargeted stable, there were conflicts when trying to rebase. Then the master branch was merged into stable, so there were conflicts again! In any case, it should be good now (I hope).

I'm glad you managed to work it out & sorry that you had to rebase this twice - bad timing :/

@wilzbach wilzbach added this to the 2.078.0 milestone Dec 20, 2017
@schveiguy
Copy link
Member Author

@jacob-carlborg I think the idea is to utilize all the existing uses of tempCString to exercise the allocation scheme. I’m not sure it makes a difference or that it will possibly find more errors, but I also didn’t write the original. Perhaps @WalterBright can shed some light.

@jacob-carlborg
Copy link
Contributor

I think the idea is to utilize all the existing uses of tempCString to exercise the allocation scheme

Aha, ok. I didn't look at tempCString, I only looked at TempCStringBuffer. I see that tempCString requires a character of some sort while it looks like TempCStringBuffer would work with any type.

@schveiguy
Copy link
Member Author

yeah, TempCStringBuffer was actually a voldemort type before a recent refactoring, so it's logical that no template constraints were added to it.

Copy link
Contributor

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

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

FWIW this is an excellent example why StdUnittest would be really useful (see #5927).

@andralex andralex merged commit 640df9f into dlang:stable Dec 20, 2017
@schveiguy schveiguy deleted the fix18084 branch December 20, 2017 18:38
wilzbach added a commit to wilzbach/phobos that referenced this pull request Dec 21, 2017
MartinNowak added a commit to schveiguy/io that referenced this pull request Jan 4, 2018
- tempCStringW was fixed with dlang/phobos#5932
@MartinNowak
Copy link
Member

Thanks, I've been running into this misterious tempCStringW bug in my io library.
schveiguy/io@6ab5a63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:Trivial typos, formatting, comments Severity:Bug Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants