-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
improvements to avoids crashes #13615
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -491,14 +491,16 @@ namespace librealsense | |
} | ||
|
||
// Enumerate all imaging devices | ||
for (int member_index = 0; ; ++member_index) | ||
// 0x10000 ia a large enough limit to permit maximum connection, while avoiding infinite loop | ||
for (DWORD member_index = 0; member_index < 0x10000; ++member_index) | ||
{ | ||
// Get device information element from the device information set | ||
if (SetupDiEnumDeviceInfo(device_info, member_index, &devInfo) == FALSE) | ||
{ | ||
if( GetLastError() == ERROR_NO_MORE_ITEMS ) | ||
break; // stop when none left | ||
continue; // silently ignore other errors | ||
DWORD last_error = GetLastError(); | ||
if ((last_error == ERROR_NO_MORE_ITEMS) || (last_error == ERROR_INVALID_HANDLE)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also explain why this was added? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The customer was complaining that the error ERROR_INVALID_HANDLE happened sometimes, and that this was leading to infinite loop (see in ticket). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this can happen when looping the devices even if not finished yet or only after. |
||
break; // stop when none left | ||
continue; // silently ignore other errors } | ||
} | ||
|
||
std::string parent_uid; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain? add comment? why <
0x10000
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only some limit to avoid infinite loop. No real meaning for this number - only assuming that there will be no system with 0x10000 (65,536) devices.
I ll add a comment.