You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/09/28 08:09:44 UTC

[GitHub] [doris] adonis0147 opened a new pull request, #13031: [Bug](aarch64) Fix the mmap errors which make BE down during starting up

adonis0147 opened a new pull request, #13031:
URL: https://github.com/apache/doris/pull/13031

   # Proposed changes
   
   Issue Number: close #13026 
   
   ## Problem summary
   
   I failed to start BE (with ASAN build type) up on Ubuntu 22.04.1 (aarch64) and got the following errors.
   ```shell
   ==46318==ERROR: AddressSanitizer failed to allocate 0x0 (0) bytes of ReadFileToBuffer (error code: 22)
   ERROR: Failed to mmap
   ```
   
   **Use `strace` to inspect the syscall**
   ```shell
   $ strace ./doris_be
   ...
   
   mmap(NULL, 0, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 EINVAL (Invalid argument)
   getpid()                                = 48376
   write(2, "==48376==ERROR: AddressSanitizer"..., 103==48376==ERROR: AddressSanitizer failed to allocate 0x0 (0) bytes of ReadFileToBuffer (error code: 22)
   ) = 103
   mmap(NULL, 0, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 EINVAL (Invalid argument)
   write(2, "ERROR: Failed to mmap\n", 22ERROR: Failed to mmap
   ) = 22
   exit_group(0)                           = ?
   +++ exited with 0 +++
   ```
   
   **The signature of mmap**
   ```cpp
   void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
   ```
   
   According to the result of `strace`, it was __**zero**__ length which caused the `Invalid argument` errors.
   
   **The implementation of function `ReadFileToBuffer` in `gcc-11-11.2.0/gcc-11.2.0/libsanitizer/sanitizer_common/sanitizer_file.cpp`**
   ```cpp
   bool ReadFileToBuffer(const char *file_name, char **buff, uptr *buff_size,
                         uptr *read_len, uptr max_len, error_t *errno_p) {
     *buff = nullptr;
     *buff_size = 0;
     *read_len = 0;
     if (!max_len)
       return true;
     uptr PageSize = GetPageSizeCached();
     uptr kMinFileLen = Min(PageSize, max_len);
   
     // The files we usually open are not seekable, so try different buffer sizes.
     for (uptr size = kMinFileLen;; size = Min(size * 2, max_len)) {
       UnmapOrDie(*buff, *buff_size);
       *buff = (char*)MmapOrDie(size, __func__);
       *buff_size = size;
       fd_t fd = OpenFile(file_name, RdOnly, errno_p);
       if (fd == kInvalidFd) {
         UnmapOrDie(*buff, *buff_size);
         return false;
       }
       *read_len = 0;
       // Read up to one page at a time.
       bool reached_eof = false;
       while (*read_len < size) {
         uptr just_read;
         if (!ReadFromFile(fd, *buff + *read_len, size - *read_len, &just_read,
                           errno_p)) {
           UnmapOrDie(*buff, *buff_size);
           CloseFile(fd);
           return false;
         }
         *read_len += just_read;
         if (just_read == 0 || *read_len == max_len) {
           reached_eof = true;
           break;
         }
       }
       CloseFile(fd);
       if (reached_eof)  // We've read the whole file.
         break;
     }
     return true;
   }
   ```
   
   It seems that `GetPageSizeCached` returned `zero` value and made the following `mmap` call fail.
   
   After investigation, I figured out that `be/src/glibc-compatibility/musl/getauxval.c` masked the `getauxval` function and made this trouble.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [x] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [ ] Yes
       - [x] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [x] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [x] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [x] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #13031: [Bug](aarch64) Fix the mmap errors which make BE down during starting up

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #13031:
URL: https://github.com/apache/doris/pull/13031#issuecomment-1260737339

   PR approved by at least one committer and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] yiguolei merged pull request #13031: [Bug](aarch64) Fix the mmap errors which make BE down during starting up

Posted by GitBox <gi...@apache.org>.
yiguolei merged PR #13031:
URL: https://github.com/apache/doris/pull/13031


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #13031: [Bug](aarch64) Fix the mmap errors which make BE down during starting up

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #13031:
URL: https://github.com/apache/doris/pull/13031#issuecomment-1260737370

   PR approved by anyone and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org