[PATCH] Make ldd stop after any non-continuable exception

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] Make ldd stop after any non-continuable exception

Jon TURNEY
Ensure that ldd always stops when the exception is flagged as
non-continuable.

Also arrange for ldd to exit with a non-zero exit code if something went
wrong which prevented us from listing all dynamic dependencies.

Signed-off-by: Jon Turney <[hidden email]>
---

Notes:
    I saw an instance of ldd which was continuously looping with the same
    STATUS_DLL_NOT_FOUND exception being reported.

 winsup/utils/ldd.cc | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/winsup/utils/ldd.cc b/winsup/utils/ldd.cc
index 8e891d8..bbc62f1 100644
--- a/winsup/utils/ldd.cc
+++ b/winsup/utils/ldd.cc
@@ -302,6 +302,9 @@ report (const char *in_fn, bool multiple)
   dlls dll_list = {};
   dlls *dll_last = &dll_list;
   const wchar_t *process_fn = NULL;
+
+  int res = 0;
+
   while (1)
     {
       bool exitnow = false;
@@ -356,6 +359,11 @@ report (const char *in_fn, bool multiple)
  TerminateProcess (hProcess, 0);
       break;
     }
+  if (ev.u.Exception.ExceptionRecord.ExceptionFlags &
+      EXCEPTION_NONCONTINUABLE) {
+    res = 1;
+    goto print_and_exit;
+  }
   break;
  case EXIT_PROCESS_DEBUG_EVENT:
 print_and_exit:
@@ -374,7 +382,7 @@ print_and_exit:
  break;
     }
 
-  return 0;
+  return res;
 }
 
 int
--
2.8.3

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Make ldd stop after any non-continuable exception

Corinna Vinschen-2
On Apr  4 18:51, Jon Turney wrote:
> Ensure that ldd always stops when the exception is flagged as
> non-continuable.
>
> Also arrange for ldd to exit with a non-zero exit code if something went
> wrong which prevented us from listing all dynamic dependencies.

Patch is ok.  In what situation occurs this?


Thanks,
Corinna

--
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Make ldd stop after any non-continuable exception

Jon TURNEY
On 05/04/2017 08:42, Corinna Vinschen wrote:
> On Apr  4 18:51, Jon Turney wrote:
>> Ensure that ldd always stops when the exception is flagged as
>> non-continuable.
>>
>> Also arrange for ldd to exit with a non-zero exit code if something went
>> wrong which prevented us from listing all dynamic dependencies.
>
> Patch is ok.  In what situation occurs this?

So...

Running the meson test suite on AppVeyor, some of the GNOME gir tests
hang.  It looks like g-ir-scanner tries to discover something by
building an executable, then running ldd on it, which was looping like this.

I can't reproduce it locally :(


Loading...