public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110730] New: STL internal allocation/deallocation might lead to core dump in the use of header units of the modules feature
@ 2023-07-19  6:43 nishuangcheng at gmail dot com
  2024-03-06 18:01 ` [Bug c++/110730] " ppalka at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: nishuangcheng at gmail dot com @ 2023-07-19  6:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110730

            Bug ID: 110730
           Summary: STL internal allocation/deallocation might lead to
                    core dump in the use of header units of the modules
                    feature
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nishuangcheng at gmail dot com
  Target Milestone: ---

---
the exact version of GCC: 14.0.0
---
the system type: Linux, Ubuntu 22.04.2 LTS, x86_64
---
the options given when GCC was configured/built:
--enable-default-pie --enable-host-pie --enable-host-shared
--enable-languages=default,go --enable-threads=posix
--with-multilib-list=m32,m64,mx32
---
the complete command line that triggers the bug and the output:
###test case1###
$ cat module-test.cpp 
import <filesystem>;

int main(int argc, char **argv) {
  return !std::filesystem::exists(argc == 1 ? std::filesystem::current_path()
                                            : argv[1]);
}

$ g++ -std=c++23 -fmodules-ts -Wall -Wextra -x c++-system-header filesystem -x
c++ module-test.cpp -o module-test

$ ./module-test # error
free(): invalid pointer
Aborted (core dumped)

$ ./module-test existing_file # ok

$ echo $?
0

$ ./module-test nonexisting_file # ok

$ echo $?
1

###end of test case1###

###test case2###
$ cat module-test.cpp 
import <filesystem>;
import <iostream>;

int main() {
  std::cout << "PWD: " << std::filesystem::current_path() << std::endl;
  return 0;
}

$ g++ -std=c++23 -fmodules-ts -Wall -Wextra -x c++-system-header filesystem
iostream -x c++ module-test.cpp -o module-test

$ ./module-test # changing the importing order produces the same result
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)
###end of test case2###
---
It seems that this is not a mere issue of multiple header-unit compilation
mentioned in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99227, since there is
only one header unit in test case1.
Besides, this is a runtime issue instead of a compile-time one. The problem is
probably related to the <filesystem> header unit. Thus, I only include its
preprocessed file in my attachments.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-26 11:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-19  6:43 [Bug c++/110730] New: STL internal allocation/deallocation might lead to core dump in the use of header units of the modules feature nishuangcheng at gmail dot com
2024-03-06 18:01 ` [Bug c++/110730] " ppalka at gcc dot gnu.org
2024-03-06 18:02 ` ppalka at gcc dot gnu.org
2024-03-06 20:06 ` ppalka at gcc dot gnu.org
2024-03-07 21:24 ` cvs-commit at gcc dot gnu.org
2024-03-07 21:25 ` ppalka at gcc dot gnu.org
2024-03-26 11:39 ` nishuangcheng at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).