Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc][riscv] Fatal error: glibc detected an invalid stdio handle #63558

Closed
mikhailramalho opened this issue Jun 27, 2023 · 4 comments
Closed
Assignees
Labels

Comments

@mikhailramalho
Copy link
Member

mikhailramalho commented Jun 27, 2023

I started to get the following error when testing the latest ToT libc in a VisionFive 2 board:

$ valgrind ./libc.test.src.stdio.ungetc_test.__build__
==51691== Memcheck, a memory error detector
==51691== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==51691== Using Valgrind-3.21.0.GIT and LibVEX; rerun with -h for copyright info
==51691== Command: ./libc.test.src.stdio.ungetc_test.__build__
==51691== 
[ RUN      ] LlvmLibcUngetcTest.UngetAndReadBack
[       OK ] LlvmLibcUngetcTest.UngetAndReadBack (took 218 ms)
Ran 1 tests.  PASS: 1  FAIL: 0
Fatal error: glibc detected an invalid stdio handle
==51691== 
==51691== Process terminating with default action of signal 6 (SIGABRT)
==51691==    at 0x4B4CC54: __pthread_kill_implementation (pthread_kill.c:44)
==51691==    by 0x4B17B89: raise (raise.c:26)
==51691==    by 0x4B08047: abort (abort.c:79)
==51691==    by 0x4B4438B: __libc_message (libc_fatal.c:150)
==51691==    by 0x4B4439D: __libc_fatal (libc_fatal.c:159)
==51691==    by 0x4B446B5: _IO_vtable_check (vtables.c:67)
==51691==    by 0x4B446B5: _IO_vtable_check (vtables.c:37)
==51691==    by 0x4B3CB91: fflush (libioP.h:945)
==51691==    by 0x494E2B9: std::ostream::flush() (in /usr/lib/riscv64-linux-gnu/libstdc++.so.6.0.31)
==51691==    by 0x48F0AF3: std::ios_base::Init::~Init() (in /usr/lib/riscv64-linux-gnu/libstdc++.so.6.0.31)
==51691==    by 0x4B19265: __cxa_finalize (cxa_finalize.c:82)
==51691==    by 0x48DF975: ??? (in /usr/lib/riscv64-linux-gnu/libstdc++.so.6.0.31)
==51691==    by 0x4000E45: _dl_call_fini (dl-call_fini.c:43)
==51691== 
==51691== HEAP SUMMARY:
==51691==     in use at exit: 73,728 bytes in 1 blocks
==51691==   total heap usage: 10 allocs, 9 frees, 76,108 bytes allocated
==51691== 
==51691== LEAK SUMMARY:
==51691==    definitely lost: 0 bytes in 0 blocks
==51691==    indirectly lost: 0 bytes in 0 blocks
==51691==      possibly lost: 0 bytes in 0 blocks
==51691==    still reachable: 73,728 bytes in 1 blocks
==51691==         suppressed: 0 bytes in 0 blocks
==51691== Rerun with --leak-check=full to see details of leaked memory
==51691== 
==51691== For lists of detected and suppressed errors, rerun with: -s
==51691== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Aborted (core dumped)

libc built with:

$ clang -v
Ubuntu clang version 15.0.7
Target: riscv64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/riscv64-linux-gnu/12
Selected GCC installation: /usr/bin/../lib/gcc/riscv64-linux-gnu/12

on:

$ uname -a
Linux ubuntu 6.2.0-23-generic #23.1-Ubuntu SMP Sat Jun  3 08:01:11 UTC 2023 riscv64 riscv64 riscv64 GNU/Linux
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 27, 2023

@llvm/issue-subscribers-libc

@michaelrj-google
Copy link
Contributor

Hi,

Sorry it's taken a while to get back to you. I have a theory as to what the problem is. My guess is that valgrind is expecting all ::FILE objects to be glibc files, and when our FILE object is created it interprets it as an invalid file. Is the crash happening when you don't run valgrind on the test?

@mikhailramalho
Copy link
Member Author

Hi,

Sorry it's taken a while to get back to you. I have a theory as to what the problem is. My guess is that valgrind is expecting all ::FILE objects to be glibc files, and when our FILE object is created it interprets it as an invalid file. Is the crash happening when you don't run valgrind on the test?

yes, and this also seems to be related to glibc 2.37.

sivachandra pushed a commit that referenced this issue Aug 17, 2023
…ct files.

This is done so that tests which only require platform file but not the
platform streams can be run as unit tests. The tests which use platform
streams can only be hermetic tests to avoid conflicts with the
system-libc streams.

Fixes:
#64663
#63558

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D158193
@jhuber6
Copy link
Contributor

jhuber6 commented Aug 17, 2023

0f6ef9b

@jhuber6 jhuber6 closed this as completed Aug 17, 2023
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 2, 2023
…ct files.

This is done so that tests which only require platform file but not the
platform streams can be run as unit tests. The tests which use platform
streams can only be hermetic tests to avoid conflicts with the
system-libc streams.

Fixes:
llvm#64663
llvm#63558

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D158193
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 2, 2023
…ct files.

This is done so that tests which only require platform file but not the
platform streams can be run as unit tests. The tests which use platform
streams can only be hermetic tests to avoid conflicts with the
system-libc streams.

Fixes:
llvm#64663
llvm#63558

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D158193
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 2, 2023
…ct files.

This is done so that tests which only require platform file but not the
platform streams can be run as unit tests. The tests which use platform
streams can only be hermetic tests to avoid conflicts with the
system-libc streams.

Fixes:
llvm#64663
llvm#63558

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D158193
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 3, 2023
…ct files.

This is done so that tests which only require platform file but not the
platform streams can be run as unit tests. The tests which use platform
streams can only be hermetic tests to avoid conflicts with the
system-libc streams.

Fixes:
llvm#64663
llvm#63558

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D158193
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 3, 2023
…ct files.

This is done so that tests which only require platform file but not the
platform streams can be run as unit tests. The tests which use platform
streams can only be hermetic tests to avoid conflicts with the
system-libc streams.

Fixes:
llvm#64663
llvm#63558

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D158193
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 6, 2023
…ct files.

This is done so that tests which only require platform file but not the
platform streams can be run as unit tests. The tests which use platform
streams can only be hermetic tests to avoid conflicts with the
system-libc streams.

Fixes:
llvm#64663
llvm#63558

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D158193
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 11, 2023
…ct files.

This is done so that tests which only require platform file but not the
platform streams can be run as unit tests. The tests which use platform
streams can only be hermetic tests to avoid conflicts with the
system-libc streams.

Fixes:
llvm#64663
llvm#63558

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D158193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants