OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 expect_behavior = 0; | 176 expect_behavior = 0; |
177 } | 177 } |
178 | 178 |
179 EXPECT_EQ(expect_behavior, behavior); | 179 EXPECT_EQ(expect_behavior, behavior); |
180 | 180 |
181 EXPECT_EQ(LocalPort(), exception_port); | 181 EXPECT_EQ(LocalPort(), exception_port); |
182 | 182 |
183 EXPECT_EQ(EXC_CRASH, exception); | 183 EXPECT_EQ(EXC_CRASH, exception); |
184 EXPECT_EQ(2u, code_count); | 184 EXPECT_EQ(2u, code_count); |
185 | 185 |
186 // The code_count check above would ideally use ASSERT_EQ so that the next | 186 // The exception and code_count checks above would ideally use ASSERT_EQ so |
187 // conditional would not be necessary, but ASSERT_* requires a function | 187 // that the next conditional would not be necessary, but ASSERT_* requires a |
188 // returning type void, and the interface dictates otherwise here. | 188 // function returning type void, and the interface dictates otherwise here. |
189 if (code_count >= 1) { | 189 if (exception == EXC_CRASH && code_count >= 1) { |
190 // The signal that terminated the process is stored in code[0] along with | 190 int signal; |
191 // some other data. See 10.9.4 xnu-2422.110.17/bsd/kern/kern_exit.c | 191 ExcCrashRecoverOriginalException(code[0], NULL, &signal); |
192 // proc_prepareexit(). | |
193 int sig = (code[0] >> 24) & 0xff; | |
194 | 192 |
195 // The child crashed with a division by zero, which shows up as SIGFPE. | 193 // The child crashed with a division by zero, which shows up as SIGFPE. |
196 // This was chosen because it’s unlikely to be generated by testing or | 194 // This was chosen because it’s unlikely to be generated by testing or |
197 // assertion failures. | 195 // assertion failures. |
198 EXPECT_EQ(SIGFPE, sig); | 196 EXPECT_EQ(SIGFPE, signal); |
199 | 197 |
200 SetExpectedChildTermination(kTerminationSignal, sig); | 198 SetExpectedChildTermination(kTerminationSignal, signal); |
201 } | 199 } |
202 | 200 |
203 // Even for an EXC_CRASH handler, returning KERN_SUCCESS with a | 201 // Even for an EXC_CRASH handler, returning KERN_SUCCESS with a |
204 // state-carrying reply will cause the kernel to try to set a new thread | 202 // state-carrying reply will cause the kernel to try to set a new thread |
205 // state, leading to a perceptible waste of time. Returning | 203 // state, leading to a perceptible waste of time. Returning |
206 // MACH_RCV_PORT_DIED is the only way to suppress this behavior while also | 204 // MACH_RCV_PORT_DIED is the only way to suppress this behavior while also |
207 // preventing the kernel from looking for another (host-level) EXC_CRASH | 205 // preventing the kernel from looking for another (host-level) EXC_CRASH |
208 // handler. See 10.9.4 xnu-2422.110.17/osfmk/kern/exception.c | 206 // handler. See 10.9.4 xnu-2422.110.17/osfmk/kern/exception.c |
209 // exception_triage(). | 207 // exception_triage(). |
210 exception_behavior_t basic_behavior = behavior & ~MACH_EXCEPTION_CODES; | 208 exception_behavior_t basic_behavior = behavior & ~MACH_EXCEPTION_CODES; |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 rv = implicit_host_ports.GetExceptionPorts( | 590 rv = implicit_host_ports.GetExceptionPorts( |
593 ExcMaskAll() | EXC_MASK_CRASH, &handlers); | 591 ExcMaskAll() | EXC_MASK_CRASH, &handlers); |
594 if (geteuid() == 0) { | 592 if (geteuid() == 0) { |
595 EXPECT_TRUE(rv); | 593 EXPECT_TRUE(rv); |
596 } else { | 594 } else { |
597 EXPECT_FALSE(rv); | 595 EXPECT_FALSE(rv); |
598 } | 596 } |
599 } | 597 } |
600 | 598 |
601 } // namespace | 599 } // namespace |
OLD | NEW |