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

ldso: dlopen could allocate a handle that was already in use #7518

Merged
merged 1 commit into from Nov 17, 2018

Conversation

navytux
Copy link
Contributor

@navytux navytux commented Nov 16, 2018

Currently dlopen allocates DSO handles by iterating loaded libraries
while counting them from 1. This would work if libraries would be never
unloaded, but it breaks in the presense of dlcose, e.g.:

dlopen('A') -> 1
dlopen('B') -> 2
dlopen('C') -> 3
dlclose('A') ; 1 is deleted from loadedLibs
dlopen('D') : should be either 1 or 4 but it gives 3, thus erroneously overwriting C.

Fix it by always using simply incrementing integer for next allocated
handle.

Suggested-by: @sbc100

Currently dlopen allocates DSO handles by iterating loaded libraries
while counting them from 1. This would work if libraries would be never
unloaded, but it breaks in the presense of dlcose, e.g.:

	dlopen('A') -> 1
	dlopen('B') -> 2
	dlopen('C') -> 3
	dlclose('A') ; 1 is deleted from loadedLibs
	dlopen('D') : should be either 1 or 4 but it gives 3, thus erroneously overwriting C.

Fix it by always using simply incrementing integer for next allocated
handle.

Suggested-by: @sbc100
@navytux
Copy link
Contributor Author

navytux commented Nov 16, 2018

( spawned from #7512 )

@sbc100 sbc100 merged commit b98e4d0 into emscripten-core:incoming Nov 17, 2018
@navytux navytux deleted the y/ldso-needed.2 branch November 20, 2018 18:48
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.

None yet

2 participants