pgrep: allows long command lines to be searched e.g. java process with long classpath

Bug #1839329 reported by Pedro Principeza
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
procps (Ubuntu)
Fix Released
Low
Eric Desrochers
Xenial
In Progress
Low
Unassigned
Bionic
Fix Released
Medium
Eric Desrochers
Disco
Fix Released
Low
Eric Desrochers

Bug Description

[Impact]
The pgrep -f and pkill -f commands are unable to find processes strings in processes which are beyond the 4096th character. This often happens with Java command lines with long classpaths on the command line.

[Test Case]
A quick test to reproduce this is to vi a file using a filename over 4k
$ vi $(seq 1 1250| paste -s -d'_')_foo.txt)
and leave vi running then run from another terminal
$ pgrep -af 'foo.txt'
to find it.

Without the fix, one will only see the first 4096 chars, while the expected behaviour would be:

$ pgrep -af 'foo.txt'
27667 vi 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16_17_18_19_20_21_22_23_24_25_26_27_28_29_30_31_32_33_34_35_36_37_38_39_40_41_42_43_44_45_46_47_48_49_50_51_52_53_54_55_56_57_58_59_60_61_62_63_64_65_66_67_68_69_70_71_72_73_74_75_76_77_78_79_80_81_82_83_84_85_86_87_88_89_90_91_92_93_94_95_96_97_98_99_100_101_102_103_104_105_106_107_108_109_110_111_112_113_114_115_116_117_118_119_120_121_122_123_124_125_126_127_128_129_130_131_132_133_134_135_136_137_138_139_140_141_142_143_144_145_146_147_148_149_150_151_152_153_154_155_156_157_158_159_160_161_162_163_164_165_166_167_168_169_170_171_172_173_174_175_176_177_178_179_180_181_182_183_184_185_186_187_188_189_190_191_192_193_194_195_196_197_198_199_200_201_202_203_204_205_206_207_208_209_210_211_212_213_214_215_216_217_218_219_220_221_222_223_224_225_226_227_228_229_230_231_232_233_234_235_236_237_238_239_240_241_242_243_244_245_246_247_248_249_250_251_252_253_254_255_256_257_258_259_260_261_262_263_264_265_266_267_268_269_270_271_272_273_274_275_276_277_278_279_280_281_282_283_284_285_286_287_288_289_290_291_292_293_294_295_296_297_298_299_300_301_302_303_304_305_306_307_308_309_310_311_312_313_314_315_316_317_318_319_320_321_322_323_324_325_326_327_328_329_330_331_332_333_334_335_336_337_338_339_340_341_342_343_344_345_346_347_348_349_350_351_352_353_354_355_356_357_358_359_360_361_362_363_364_365_366_367_368_369_370_371_372_373_374_375_376_377_378_379_380_381_382_383_384_385_386_387_388_389_390_391_392_393_394_395_396_397_398_399_400_401_402_403_404_405_406_407_408_409_410_411_412_413_414_415_416_417_418_419_420_421_422_423_424_425_426_427_428_429_430_431_432_433_434_435_436_437_438_439_440_441_442_443_444_445_446_447_448_449_450_451_452_453_454_455_456_457_458_459_460_461_462_463_464_465_466_467_468_469_470_471_472_473_474_475_476_477_478_479_480_481_482_483_484_485_486_487_488_489_490_491_492_493_494_495_496_497_498_499_500_501_502_503_504_505_506_507_508_509_510_511_512_513_514_515_516_517_518_519_520_521_522_523_524_525_526_527_528_529_530_531_532_533_534_535_536_537_538_539_540_541_542_543_544_545_546_547_548_549_550_551_552_553_554_555_556_557_558_559_560_561_562_563_564_565_566_567_568_569_570_571_572_573_574_575_576_577_578_579_580_581_582_583_584_585_586_587_588_589_590_591_592_593_594_595_596_597_598_599_600_601_602_603_604_605_606_607_608_609_610_611_612_613_614_615_616_617_618_619_620_621_622_623_624_625_626_627_628_629_630_631_632_633_634_635_636_637_638_639_640_641_642_643_644_645_646_647_648_649_650_651_652_653_654_655_656_657_658_659_660_661_662_663_664_665_666_667_668_669_670_671_672_673_674_675_676_677_678_679_680_681_682_683_684_685_686_687_688_689_690_691_692_693_694_695_696_697_698_699_700_701_702_703_704_705_706_707_708_709_710_711_712_713_714_715_716_717_718_719_720_721_722_723_724_725_726_727_728_729_730_731_732_733_734_735_736_737_738_739_740_741_742_743_744_745_746_747_748_749_750_751_752_753_754_755_756_757_758_759_760_761_762_763_764_765_766_767_768_769_770_771_772_773_774_775_776_777_778_779_780_781_782_783_784_785_786_787_788_789_790_791_792_793_794_795_796_797_798_799_800_801_802_803_804_805_806_807_808_809_810_811_812_813_814_815_816_817_818_819_820_821_822_823_824_825_826_827_828_829_830_831_832_833_834_835_836_837_838_839_840_841_842_843_844_845_846_847_848_849_850_851_852_853_854_855_856_857_858_859_860_861_862_863_864_865_866_867_868_869_870_871_872_873_874_875_876_877_878_879_880_881_882_883_884_885_886_887_888_889_890_891_892_893_894_895_896_897_898_899_900_901_902_903_904_905_906_907_908_909_910_911_912_913_914_915_916_917_918_919_920_921_922_923_924_925_926_927_928_929_930_931_932_933_934_935_936_937_938_939_940_941_942_943_944_945_946_947_948_949_950_951_952_953_954_955_956_957_958_959_960_961_962_963_964_965_966_967_968_969_970_971_972_973_974_975_976_977_978_979_980_981_982_983_984_985_986_987_988_989_990_991_992_993_994_995_996_997_998_999_1000_1001_1002_1003_1004_1005_1006_1007_1008_1009_1010_1011_1012_1013_1014_1015_1016_1017_1018_1019_1020_1021_1022_1023_1024_1025_1026_1027_1028_1029_1030_1031_1032_1033_1034_1035_1036_1037_1038_1039_1040_1041_1042_1043_1044_1045_1046_1047_1048_1049_1050_1051_1052_1053_1054_1055_1056_1057_1058_1059_1060_1061_1062_1063_1064_1065_1066_1067_1068_1069_1070_1071_1072_1073_1074_1075_1076_1077_1078_1079_1080_1081_1082_1083_1084_1085_1086_1087_1088_1089_1090_1091_1092_1093_1094_1095_1096_1097_1098_1099_1100_1101_1102_1103_1104_1105_1106_1107_1108_1109_1110_1111_1112_1113_1114_1115_1116_1117_1118_1119_1120_1121_1122_1123_1124_1125_1126_1127_1128_1129_1130_1131_1132_1133_1134_1135_1136_1137_1138_1139_1140_1141_1142_1143_1144_1145_1146_1147_1148_1149_1150_1151_1152_1153_1154_1155_1156_1157_1158_1159_1160_1161_1162_1163_1164_1165_1166_1167_1168_1169_1170_1171_1172_1173_1174_1175_1176_1177_1178_1179_1180_1181_1182_1183_1184_1185_1186_1187_1188_1189_1190_1191_1192_1193_1194_1195_1196_1197_1198_1199_1200_1201_1202_1203_1204_1205_1206_1207_1208_1209_1210_1211_1212_1213_1214_1215_1216_1217_1218_1219_1220_1221_1222_1223_1224_1225_1226_1227_1228_1229_1230_1231_1232_1233_1234_1235_1236_1237_1238_1239_1240_1241_1242_1243_1244_1245_1246_1247_1248_1249_1250_foo.txt

[Potential Regression]
The proposal merge are a few months old, and no upstream comment/involvement since then.

If we fix that in Ubuntu, we will have to carry the patch at each release until Upstream take action (if they take action one day). The patch is simple and easy to carry over.

The potential regression could be that one discard the patch in future merge, and re-introduce the previous CMDSTRSIZE value.(Due to the fact that upstream haven't accept the patch yet)

I don't foresee any problem in increasing the value from "4096 to "16384".
IMHO, it's a little bit too much, but will benefit user who uses java application with long classpath.

[Other Infos]
This bug is a mirror of what has already been reported in GitLab, through the merge request #85 [1], and has been previously reported at the merge request #80 [2], with no response/reply.

Let me know if further information is needed, at this point, to proceed. Thanks!

[1] https://gitlab.com/procps-ng/procps/merge_requests/85
[2] https://gitlab.com/procps-ng/procps/merge_requests/80

Upstream discussion:
https://www.freelists.org/post/procps/Extending-pgrep-to-more-than-4k-cmd-length

Eric Desrochers (slashd)
tags: added: sts
Changed in procps (Ubuntu):
importance: Undecided → Low
assignee: nobody → Eric Desrochers (slashd)
status: New → In Progress
description: updated
Revision history for this message
Eric Desrochers (slashd) wrote :

The '-a' flag[0] which should list the full cmd line seems to be limited to 4096 chars[1].

In most case it is more than enough, but not always the case for java processes with long classpaths for instance as describe in the bug description.

[0] -a, --list-full
              List the full command line as well as the process ID. (pgrep only.)

[1] pgrep.c
     44
     45 #define CMDSTRSIZE 4096
     46

Eric Desrochers (slashd)
description: updated
Eric Desrochers (slashd)
description: updated
description: updated
Eric Desrochers (slashd)
description: updated
Eric Desrochers (slashd)
description: updated
Eric Desrochers (slashd)
description: updated
Changed in procps (Ubuntu Xenial):
status: New → In Progress
Changed in procps (Ubuntu Bionic):
status: New → In Progress
Changed in procps (Ubuntu Disco):
status: New → In Progress
Changed in procps (Ubuntu Xenial):
assignee: nobody → Eric Desrochers (slashd)
Changed in procps (Ubuntu Bionic):
assignee: nobody → Eric Desrochers (slashd)
Changed in procps (Ubuntu Disco):
assignee: nobody → Eric Desrochers (slashd)
Eric Desrochers (slashd)
Changed in procps (Ubuntu Bionic):
importance: Undecided → Medium
Changed in procps (Ubuntu Disco):
importance: Undecided → Low
Changed in procps (Ubuntu Xenial):
importance: Undecided → Low
Eric Desrochers (slashd)
Changed in procps (Ubuntu):
status: In Progress → Fix Committed
summary: - pgrep: Use POSIX _SC_ARG_MAX for maximum pgrep -f command line length
+ pgrep: allows long command lines to be searched e.g. java process with
+ long classpath
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package procps - 2:3.3.15-2ubuntu3

---------------
procps (2:3.3.15-2ubuntu3) eoan; urgency=medium

  * d/p/pgrep-increase-CMDSTRSIZE.patch:
    - Allows long command lines to be searched.
    eg: Java process with a long classpath. (LP: #1839329)

 -- Eric Desrochers <email address hidden> Thu, 08 Aug 2019 16:46:48 +0000

Changed in procps (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Ok, change seems to be trivial enough to accept even without getting this merged upstream (most important is that there was no disagreement so far from the maintainers). I also don't expect anything to go bad since the constant bump is not too big anyway.

Changed in procps (Ubuntu Disco):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-disco
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Please test proposed package

Hello Pedro, or anyone else affected,

Accepted procps into disco-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/procps/2:3.3.15-2ubuntu2.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-disco to verification-done-disco. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-disco. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Hello Pedro, or anyone else affected,

Accepted procps into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/procps/2:3.3.12-3ubuntu1.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in procps (Ubuntu Bionic):
status: In Progress → Fix Committed
tags: added: verification-needed-bionic
Revision history for this message
Eric Desrochers (slashd) wrote :
Download full text (5.3 KiB)

[VERIFICATION BIONIC]

I have installed the bionic-proposed 'procps' package and was able to conclude that it fixes the situation based on the reproducer suggested upstream:

$ vi $(seq 1 1250| paste -s -d'_')_foo.txt # Creating a process containing > 4096 chars, to be precise 5158 chars)
$ pgrep -af 'foo.txt'
1148 vi 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16_17_18_19_20_21_22_23_24_25_26_27_28_29_30_31_32_33_34_35_36_37_38_39_40_41_42_43_44_45_46_47_48_49_50_51_52_53_54_55_56_57_58_59_60_61_62_63_64_65_66_67_68_69_70_71_72_73_74_75_76_77_78_79_80_81_82_83_84_85_86_87_88_89_90_91_92_93_94_95_96_97_98_99_100_101_102_103_104_105_106_107_108_109_110_111_112_113_114_115_116_117_118_119_120_121_122_123_124_125_126_127_128_129_130_131_132_133_134_135_136_137_138_139_140_141_142_143_144_145_146_147_148_149_150_151_152_153_154_155_156_157_158_159_160_161_162_163_164_165_166_167_168_169_170_171_172_173_174_175_176_177_178_179_180_181_182_183_184_185_186_187_188_189_190_191_192_193_194_195_196_197_198_199_200_201_202_203_204_205_206_207_208_209_210_211_212_213_214_215_216_217_218_219_220_221_222_223_224_225_226_227_228_229_230_231_232_233_234_235_236_237_238_239_240_241_242_243_244_245_246_247_248_249_250_251_252_253_254_255_256_257_258_259_260_261_262_263_264_265_266_267_268_269_270_271_272_273_274_275_276_277_278_279_280_281_282_283_284_285_286_287_288_289_290_291_292_293_294_295_296_297_298_299_300_301_302_303_304_305_306_307_308_309_310_311_312_313_314_315_316_317_318_319_320_321_322_323_324_325_326_327_328_329_330_331_332_333_334_335_336_337_338_339_340_341_342_343_344_345_346_347_348_349_350_351_352_353_354_355_356_357_358_359_360_361_362_363_364_365_366_367_368_369_370_371_372_373_374_375_376_377_378_379_380_381_382_383_384_385_386_387_388_389_390_391_392_393_394_395_396_397_398_399_400_401_402_403_404_405_406_407_408_409_410_411_412_413_414_415_416_417_418_419_420_421_422_423_424_425_426_427_428_429_430_431_432_433_434_435_436_437_438_439_440_441_442_443_444_445_446_447_448_449_450_451_452_453_454_455_456_457_458_459_460_461_462_463_464_465_466_467_468_469_470_471_472_473_474_475_476_477_478_479_480_481_482_483_484_485_486_487_488_489_490_491_492_493_494_495_496_497_498_499_500_501_502_503_504_505_506_507_508_509_510_511_512_513_514_515_516_517_518_519_520_521_522_523_524_525_526_527_528_529_530_531_532_533_534_535_536_537_538_539_540_541_542_543_544_545_546_547_548_549_550_551_552_553_554_555_556_557_558_559_560_561_562_563_564_565_566_567_568_569_570_571_572_573_574_575_576_577_578_579_580_581_582_583_584_585_586_587_588_589_590_591_592_593_594_595_596_597_598_599_600_601_602_603_604_605_606_607_608_609_610_611_612_613_614_615_616_617_618_619_620_621_622_623_624_625_626_627_628_629_630_631_632_633_634_635_636_637_638_639_640_641_642_643_644_645_646_647_648_649_650_651_652_653_654_655_656_657_658_659_660_661_662_663_664_665_666_667_668_669_670_671_672_673_674_675_676_677_678_679_680_681_682_683_684_685_686_687_688_689_690_691_692_693_694_695_696_697_698_699_700_701_702_703_704_705_706_707_708_709_710_711_712_713_714_715_716_717_718_719_720_721_722_723_724_725_726_727_728_729_730_731_732_733_734_735_736_737_738_739_740_741_742_743_744_745_746_747_...

Read more...

tags: added: verification-done-bionic
removed: verification-needed-bionic
Revision history for this message
Eric Desrochers (slashd) wrote :
Download full text (5.3 KiB)

[VERIFICATION DISCO]

I have installed the disco-proposed 'procps' package and was able to conclude that it fixes the situation based on the reproducer suggested upstream:

$ vi $(seq 1 1250| paste -s -d'_')_foo.txt # Creating a process containing > 4096 chars, to be precise 5158 chars)
$ pgrep -af 'foo.txt'
1148 vi 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16_17_18_19_20_21_22_23_24_25_26_27_28_29_30_31_32_33_34_35_36_37_38_39_40_41_42_43_44_45_46_47_48_49_50_51_52_53_54_55_56_57_58_59_60_61_62_63_64_65_66_67_68_69_70_71_72_73_74_75_76_77_78_79_80_81_82_83_84_85_86_87_88_89_90_91_92_93_94_95_96_97_98_99_100_101_102_103_104_105_106_107_108_109_110_111_112_113_114_115_116_117_118_119_120_121_122_123_124_125_126_127_128_129_130_131_132_133_134_135_136_137_138_139_140_141_142_143_144_145_146_147_148_149_150_151_152_153_154_155_156_157_158_159_160_161_162_163_164_165_166_167_168_169_170_171_172_173_174_175_176_177_178_179_180_181_182_183_184_185_186_187_188_189_190_191_192_193_194_195_196_197_198_199_200_201_202_203_204_205_206_207_208_209_210_211_212_213_214_215_216_217_218_219_220_221_222_223_224_225_226_227_228_229_230_231_232_233_234_235_236_237_238_239_240_241_242_243_244_245_246_247_248_249_250_251_252_253_254_255_256_257_258_259_260_261_262_263_264_265_266_267_268_269_270_271_272_273_274_275_276_277_278_279_280_281_282_283_284_285_286_287_288_289_290_291_292_293_294_295_296_297_298_299_300_301_302_303_304_305_306_307_308_309_310_311_312_313_314_315_316_317_318_319_320_321_322_323_324_325_326_327_328_329_330_331_332_333_334_335_336_337_338_339_340_341_342_343_344_345_346_347_348_349_350_351_352_353_354_355_356_357_358_359_360_361_362_363_364_365_366_367_368_369_370_371_372_373_374_375_376_377_378_379_380_381_382_383_384_385_386_387_388_389_390_391_392_393_394_395_396_397_398_399_400_401_402_403_404_405_406_407_408_409_410_411_412_413_414_415_416_417_418_419_420_421_422_423_424_425_426_427_428_429_430_431_432_433_434_435_436_437_438_439_440_441_442_443_444_445_446_447_448_449_450_451_452_453_454_455_456_457_458_459_460_461_462_463_464_465_466_467_468_469_470_471_472_473_474_475_476_477_478_479_480_481_482_483_484_485_486_487_488_489_490_491_492_493_494_495_496_497_498_499_500_501_502_503_504_505_506_507_508_509_510_511_512_513_514_515_516_517_518_519_520_521_522_523_524_525_526_527_528_529_530_531_532_533_534_535_536_537_538_539_540_541_542_543_544_545_546_547_548_549_550_551_552_553_554_555_556_557_558_559_560_561_562_563_564_565_566_567_568_569_570_571_572_573_574_575_576_577_578_579_580_581_582_583_584_585_586_587_588_589_590_591_592_593_594_595_596_597_598_599_600_601_602_603_604_605_606_607_608_609_610_611_612_613_614_615_616_617_618_619_620_621_622_623_624_625_626_627_628_629_630_631_632_633_634_635_636_637_638_639_640_641_642_643_644_645_646_647_648_649_650_651_652_653_654_655_656_657_658_659_660_661_662_663_664_665_666_667_668_669_670_671_672_673_674_675_676_677_678_679_680_681_682_683_684_685_686_687_688_689_690_691_692_693_694_695_696_697_698_699_700_701_702_703_704_705_706_707_708_709_710_711_712_713_714_715_716_717_718_719_720_721_722_723_724_725_726_727_728_729_730_731_732_733_734_735_736_737_738_739_740_741_742_743_744_745_746_747_74...

Read more...

tags: added: verification-done-disco
removed: verification-needed-disco
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for procps has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package procps - 2:3.3.15-2ubuntu2.1

---------------
procps (2:3.3.15-2ubuntu2.1) disco; urgency=medium

  * d/p/pgrep-increase-CMDSTRSIZE.patch:
    - Allows long command lines to be searched.
    eg: Java process with a long classpath. (LP: #1839329)

 -- Eric Desrochers <email address hidden> Fri, 09 Aug 2019 15:14:56 +0000

Changed in procps (Ubuntu Disco):
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package procps - 2:3.3.12-3ubuntu1.2

---------------
procps (2:3.3.12-3ubuntu1.2) bionic; urgency=medium

  * d/p/pgrep-increase-CMDSTRSIZE.patch:
    - Allows long command lines to be searched.
    eg: Java process with a long classpath. (LP: #1839329)

 -- Eric Desrochers <email address hidden> Fri, 09 Aug 2019 15:37:27 +0000

Changed in procps (Ubuntu Bionic):
status: Fix Committed → Fix Released
Eric Desrochers (slashd)
Changed in procps (Ubuntu Xenial):
assignee: Eric Desrochers (slashd) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.