Skip to content

Fixes [SR-78] swift compiler seg fault #291

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

Closed
wants to merge 7 commits into from
Closed

Fixes [SR-78] swift compiler seg fault #291

wants to merge 7 commits into from

Conversation

manavgabhawala
Copy link
Contributor

Fixes SR-78 swift compiler segmentation fault. The IRGen module would crash when a generic (empty) struct was part of the source code because it tried to call std::next on an end iterator, adds in a guard to prevent against that and also adds a test case to add in this check.

Added test case that caused the old compiler to crash (I'm not sure if this is the right way to integrate it in the testing suite).

Uses the aligned_alloc C function from the stdlib instead of malloc so that incase the alignMask is larger than what the system supports we do not get unnecessary crashes.
Fixes a segmentation fault where the IRGen module would crash when a
generic (empty) struct was part of the source code because it tried to
call std::next on an end iterator.
@nadavrot
Copy link
Contributor

nadavrot commented Dec 7, 2015

@manavgabhawala I prefer not to merge this change because it has a bunch of changes to different files. Some of the commit messages are not informative, like "Update Heap.cpp", twice.

Please submit a new pull request with a single commit that includes a fix for a single issue with a testcase.

@@ -2032,6 +2032,10 @@ SILType irgen::getSingletonAggregateFieldType(IRGenModule &IGM,
// If there's only one stored property, we have the layout of its field.
auto allFields = structDecl->getStoredProperties();
auto field = allFields.begin();
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be better to check for empty here?

if (allFields.empty()) {
  return SILType();
}

Copy link

Choose a reason for hiding this comment

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

Yes

@manavgabhawala
Copy link
Contributor Author

Sorry about the multiple commits, I was trying to get my feet wet. I created a new clean pull request and included the suggestion by @AlexDenisov. Moved to #293

slavapestov pushed a commit to slavapestov/swift that referenced this pull request Nov 27, 2018
…xtended-tests

Revert "Fix compilation warnings in extended test suite"
freak4pc pushed a commit to freak4pc/swift that referenced this pull request Sep 28, 2022
Add Xcode 10.1 configuration to project_precommit_check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants