summary refs log tree commit diff stats
path: root/results/classifier/user-mode-bugs/1895
blob: d23520f4715964be26a5c3b7def981cd59e1584e (plain) (blame)
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
qemu-user uses fixed stack size and ignores RLIMIT_STACK request, causing some guest programs to crash
Description of problem:
When compiling a source file, g++ segmentation faults in qemu-user riscv64. But it doesn't fail on real riscv64 boards.

We discovered this problem while compiling nodejs-lts-hydrogen. The source file has been reduced to 5KB by cvise.
Steps to reproduce:
1. Setup an Arch Linux riscv64 qemu-user container: https://github.com/felixonmars/archriscv-packages/wiki/Setup-Arch-Linux-RISC-V-Development-Environment
2. Start the container: `sudo systemd-nspawn -D ./archriscv -a -U`
3. Install gcc inside the container: `sudo pacman -Syu gcc`
4. Run the following command in the container: `g++ -S testcase.i -w -fpreprocessed -o /dev/null` [testcase.i](/uploads/d63b1867a458a240ef0d90c760d76bc7/testcase.i)
5. g++ segmentation faults: `g++: internal compiler error: Segmentation fault signal terminated program cc1plus`
Additional information:
Initially I thought this is a g++ bug. But I can't reproduce this bug on real riscv64 hardware.

g++ version: g++ (GCC) 13.2.1 20230801

testcase.i:

```c++
namespace std {
typedef long unsigned size_t;
inline namespace __cxx11 {}
} // namespace std
typedef char uint8_t;
namespace std {
template <typename _Default, typename, template <typename> class>
struct __detector {
  using type = _Default;
};
template <typename _Default, template <typename> class _Op>
using __detected_or = __detector<_Default, void, _Op>;
template <typename _Default, template <typename> class _Op>
using __detected_or_t = typename __detected_or<_Default, _Op>::type;
template <typename> class allocator;
namespace __cxx11 {
template <typename _CharT, typename = _CharT, typename = allocator<_CharT>>
class basic_string;
}
typedef basic_string<char> string;
} // namespace std
template <typename _Tp> class __new_allocator {
public:
  typedef _Tp value_type;
};
namespace std {
template <typename _Tp> using __allocator_base = __new_allocator<_Tp>;
template <typename _Tp> class allocator : public __allocator_base<_Tp> {};
template <class _E> class initializer_list {
  typedef size_t size_type;
  typedef _E *iterator;
  iterator _M_array;
  size_type _M_len;
};
struct __allocator_traits_base {
  template <typename _Tp> using __pointer = typename _Tp::const_pointer;
};
template <typename _Alloc> struct allocator_traits : __allocator_traits_base {
  typedef typename _Alloc::value_type value_type;
  using pointer = __detected_or_t<value_type, __pointer>;
};
} // namespace std
namespace __gnu_cxx {
template <typename _Alloc>
struct __alloc_traits : std::allocator_traits<_Alloc> {};
} // namespace __gnu_cxx
namespace std {
namespace __cxx11 {
template <typename _CharT, typename, typename _Alloc> class basic_string {
  typedef __gnu_cxx::__alloc_traits<_Alloc> _Alloc_traits;

public:
  typedef typename _Alloc_traits::pointer pointer;
  struct _Alloc_hider {
    _Alloc_hider(pointer, _Alloc);
  } _M_dataplus;
  pointer _M_local_data();
  basic_string(_CharT *, _Alloc __a = _Alloc())
      : _M_dataplus(_M_local_data(), __a) {}
  ~basic_string();
};
} // namespace __cxx11
} // namespace std
namespace v8 {
class StartupData {};
} // namespace v8
namespace std {
template <typename _Tp> class vector {
public:
  typedef _Tp value_type;
  vector(initializer_list<value_type>);
};
namespace builtins {
struct CodeCacheInfo {
  string id;
  vector<uint8_t> data;
};
} // namespace builtins
struct IsolateDataSerializeInfo {};
struct EnvSerializeInfo {};
struct SnapshotMetadata {
  enum { kDefault } type;
  string node_version;
  string node_arch;
  string v8_cache_version_tag;
};
struct SnapshotData {
  enum { kNotOwned } data_ownership;
  SnapshotMetadata metadata;
  v8::StartupData v8_snapshot_blob_data;
  IsolateDataSerializeInfo isolate_data_info;
  EnvSerializeInfo env_info;
  vector<builtins::CodeCacheInfo> code_cache;
} snapshot_data{
    SnapshotData::kNotOwned,
    SnapshotMetadata::kDefault,
    "",
    "",
    "",
    {},
    {},
    {},
    {{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
     {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}}};
} // namespace std
```