From: SourceForge.net <no...@so...> - 2007-05-09 10:13:45
|
Bugs item #1537172, was opened at 2006-08-09 06:18 Message generated for change (Comment added) made by subrata_modak You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=103382&aid=1537172&group_id=3382 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Testcases Group: Inter-Process Comm. (IPC) >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Kongh (bstqc-kh) Assigned to: mreed (mreed10) Summary: Improper condition decision of mmap() Initial Comment: ltp-full- 20060717\testcases\kernel\ipc\ipc_stress\shmem_test_02. c After type "./shmem_test_02", I got the error message: ERROR [line: 183] mmap failed: Success ------------------------------------------ Checking code: 179: shmem_size = sizeof (unsigned long); 180: if ((long)(checksum = (unsigned long *) 181: mmap (0, shmem_size, PROT_READ | PROT_WRITE, 182: MAP_ANON | MAP_SHARED, - 1, 0)) < 0) 183: sys_error ("mmap failed", __LINE__); mmap() here is supposed to do a anonymous mapping, if mmap() exit unsuccessful, it returns '-1', but I don't think "< 0" can work correctly everywhere and everywhen. consider the range of "unsigned long" and "long": long: -2147483648~2147483647 unsigned long: 0~4294967295 if a "unsigned long" number is large than 2147483647 and be transformed to "long" violently, something unsupposed would happen. in my test, I got value 3086903536 from (unsigned long *)mmap(...) , after transforming to "long", it turned to -1208053760 and triggered the sys_error("mmap failed", __LINE__). Maybe it's more wise of changing the determinant condition "< 0" to " == -1" . ---------------------------------------------------------------------- >Comment By: Subrata (subrata_modak) Date: 2007-05-09 10:13 Message: Logged In: YES user_id=1737361 Originator: NO Fix included into Code. Regards-- Subrata ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=103382&aid=1537172&group_id=3382 |