Skip to content

[dmd-cxx] Backport add toTypeFunction() to catch bad casts#9054

Merged
thewilsonator merged 1 commit intodlang:dmd-cxxfrom
ibuclaw:dmd-cxx-badcast
Dec 9, 2018
Merged

[dmd-cxx] Backport add toTypeFunction() to catch bad casts#9054
thewilsonator merged 1 commit intodlang:dmd-cxxfrom
ibuclaw:dmd-cxx-badcast

Conversation

@ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Dec 9, 2018

Backport from #6643. When running D2 testsuite with ubsan build, it was throwing errors in FuncDeclaration::semantic.

e.g:

fail_compilation/imports/a13311.d:8:5: error: undefined identifier ‘PieceTree’
func.c:557: runtime error: load of value 217, which is not a valid value for type 'bool'
func.c:562: runtime error: load of value 16384, which is not a valid value for type 'TRUST'
func.c:564: runtime error: load of value 16384, which is not a valid value for type 'TRUST'
func.c:565: runtime error: load of value 16384, which is not a valid value for type 'TRUST'
func.c:566: runtime error: load of value 16384, which is not a valid value for type 'TRUST'
func.c:583: runtime error: load of value 144, which is not a valid value for type 'bool'

This was because of blind casting from TypeError to TypeFunction, which was fixed in master by this PR.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @ibuclaw!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "dmd-cxx + dmd#9054"

@thewilsonator thewilsonator merged commit 237ca3f into dlang:dmd-cxx Dec 9, 2018
@ibuclaw ibuclaw deleted the dmd-cxx-badcast branch December 10, 2018 00:45
kraj pushed a commit to kraj/gcc that referenced this pull request Dec 17, 2018
Backports a fix where a bad cast to TypeFunction resulted in memory
corruption.  The logic in the function semantic has been fixed, and
casts have been replaced with a function call to always check the
front-end AST node value.

Reviewed-on: dlang/dmd#9054

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267207 138bc75d-0d04-0410-961f-82ee72b054a4
asiekierka pushed a commit to WonderfulToolchain/gcc that referenced this pull request May 16, 2022
Backports a fix where a bad cast to TypeFunction resulted in memory
corruption.  The logic in the function semantic has been fixed, and
casts have been replaced with a function call to always check the
front-end AST node value.

Reviewed-on: dlang/dmd#9054

From-SVN: r267207
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants