You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.6 KiB

  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 5.0
  4. Patch-ID: bash50-005
  5. Bug-Reported-by: Brad Spencer <bspencer@blackberry.com>
  6. Bug-Reference-ID: <1b993ff2-ce4f-662a-6be4-393457362e47@blackberry.com>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2019-01/msg00250.html
  8. Bug-Description:
  9. In certain cases, bash optimizes out a fork() call too early and prevents
  10. traps from running.
  11. Patch (apply with `patch -p0'):
  12. *** a/command.h 2018-07-20 21:16:31.000000000 -0400
  13. --- b/command.h 2019-02-20 11:09:36.000000000 -0500
  14. ***************
  15. *** 187,190 ****
  16. --- 188,192 ----
  17. #define CMD_LASTPIPE 0x2000
  18. #define CMD_STDPATH 0x4000 /* use standard path for command lookup */
  19. + #define CMD_TRY_OPTIMIZING 0x8000 /* try to optimize this simple command */
  20. /* What a command looks like. */
  21. *** a/builtins/evalstring.c 2018-12-26 11:19:21.000000000 -0500
  22. --- b/builtins/evalstring.c 2019-01-29 14:15:19.000000000 -0500
  23. ***************
  24. *** 101,104 ****
  25. --- 101,113 ----
  26. }
  27. + int
  28. + can_optimize_connection (command)
  29. + COMMAND *command;
  30. + {
  31. + return (*bash_input.location.string == '\0' &&
  32. + (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR || command->value.Connection->connector == ';') &&
  33. + command->value.Connection->second->type == cm_simple);
  34. + }
  35. +
  36. void
  37. optimize_fork (command)
  38. ***************
  39. *** 106,110 ****
  40. {
  41. if (command->type == cm_connection &&
  42. ! (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR) &&
  43. should_suppress_fork (command->value.Connection->second))
  44. {
  45. --- 115,120 ----
  46. {
  47. if (command->type == cm_connection &&
  48. ! (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR || command->value.Connection->connector == ';') &&
  49. ! (command->value.Connection->second->flags & CMD_TRY_OPTIMIZING) &&
  50. should_suppress_fork (command->value.Connection->second))
  51. {
  52. ***************
  53. *** 413,418 ****
  54. command->value.Simple->flags |= CMD_NO_FORK;
  55. }
  56. ! else if (command->type == cm_connection)
  57. ! optimize_fork (command);
  58. #endif /* ONESHOT */
  59. --- 423,438 ----
  60. command->value.Simple->flags |= CMD_NO_FORK;
  61. }
  62. !
  63. ! /* Can't optimize forks out here execept for simple commands.
  64. ! This knows that the parser sets up commands as left-side heavy
  65. ! (&& and || are left-associative) and after the single parse,
  66. ! if we are at the end of the command string, the last in a
  67. ! series of connection commands is
  68. ! command->value.Connection->second. */
  69. ! else if (command->type == cm_connection && can_optimize_connection (command))
  70. ! {
  71. ! command->value.Connection->second->flags |= CMD_TRY_OPTIMIZING;
  72. ! command->value.Connection->second->value.Simple->flags |= CMD_TRY_OPTIMIZING;
  73. ! }
  74. #endif /* ONESHOT */
  75. *** a/execute_cmd.c 2018-12-05 09:05:14.000000000 -0500
  76. --- b/execute_cmd.c 2019-01-25 15:59:00.000000000 -0500
  77. ***************
  78. *** 2768,2771 ****
  79. --- 2768,2773 ----
  80. (exec_result != EXECUTION_SUCCESS)))
  81. {
  82. + optimize_fork (command);
  83. +
  84. second = command->value.Connection->second;
  85. if (ignore_return && second)
  86. *** a/patchlevel.h 2016-06-22 14:51:03.000000000 -0400
  87. --- b/patchlevel.h 2016-10-01 11:01:28.000000000 -0400
  88. ***************
  89. *** 26,30 ****
  90. looks for to find the patch level (for the sccs version string). */
  91. ! #define PATCHLEVEL 4
  92. #endif /* _PATCHLEVEL_H_ */
  93. --- 26,30 ----
  94. looks for to find the patch level (for the sccs version string). */
  95. ! #define PATCHLEVEL 5
  96. #endif /* _PATCHLEVEL_H_ */