Skip to content

lua: align the allocated memory#6599

Merged
lizan merged 5 commits intoenvoyproxy:masterfrom
lizan:lua_align
Apr 16, 2019
Merged

lua: align the allocated memory#6599
lizan merged 5 commits intoenvoyproxy:masterfrom
lizan:lua_align

Conversation

@lizan
Copy link
Member

@lizan lizan commented Apr 16, 2019

Description:
This patch aligns the memory that is allocated by Lua. Previously, without alignment, Envoy experienced segfault when constructing StreamWrapperHandler using the placement new operator on the pre-allocated (via new_luauserdata API) memory by Lua.

Risk Level: Medium for Lua users.
Testing: Enable test in UBSAN on Linux as well.
Docs Changes: N/A
Release Notes: N/A
Fixes #5551

lizan added 2 commits April 16, 2019 09:10
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Dhi Aurrahman <dio@tetrate.io>
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
@lizan lizan requested a review from dio April 16, 2019 10:13
@htuch htuch requested a review from mattklein123 April 16, 2019 15:01
@htuch
Copy link
Member

htuch commented Apr 16, 2019

@lizan do you think this will make those remaining ASAN issues I was encountering a while back go away?

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks, glad to see this fixed. Few small comments.

/wait

}

template <typename T> inline T* alignAndCast(void* mem) {
size_t size = maximumSpaceNeededToAlign<T>();
Copy link
Member

Choose a reason for hiding this comment

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

nit: const or just inline the call below.

Copy link
Member Author

Choose a reason for hiding this comment

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

4th parameter of std::align takes size_t& so this cannot be a const or inlined.

lizan added 2 commits April 16, 2019 17:08
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Nice, thanks.

@lizan
Copy link
Member Author

lizan commented Apr 16, 2019

@htuch I missed you comment, what are the remaining ASAN issues?

@htuch
Copy link
Member

htuch commented Apr 16, 2019

#6196

@lizan lizan merged commit f235f56 into envoyproxy:master Apr 16, 2019
@lizan
Copy link
Member Author

lizan commented Apr 16, 2019

@htuch possibly, let me try on that

@dio
Copy link
Member

dio commented Apr 16, 2019

Thanks @lizan 🙇

duderino pushed a commit to istio/envoy that referenced this pull request Aug 13, 2019
Description:
This patch aligns the memory that is allocated by Lua. Previously, without alignment, Envoy experienced segfault when constructing `StreamWrapperHandler` using the placement new operator on the pre-allocated (via `new_luauserdata` API) memory by Lua.

Risk Level: Medium for Lua users.
Testing: Enable test in UBSAN on Linux as well.
Docs Changes: N/A
Release Notes: N/A
Fixes envoyproxy#5551

Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
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.

lua, osx: envoy with lua http HTTP filter enabled crashes on release build

4 participants