mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
7187454: stack overflow in C2 compiler thread on Solaris x86
Added new FormatBufferResource class to use thread's resource area for error message buffer. Reviewed-by: twisti
This commit is contained in:
parent
b9eb5785cc
commit
5e05a0d592
11 changed files with 42 additions and 23 deletions
|
@ -31,29 +31,43 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
// Simple class to format the ctor arguments into a fixed-sized buffer.
|
||||
class FormatBufferBase {
|
||||
protected:
|
||||
char* _buf;
|
||||
inline FormatBufferBase(char* buf) : _buf(buf) {}
|
||||
public:
|
||||
operator const char *() const { return _buf; }
|
||||
};
|
||||
|
||||
// Use resource area for buffer
|
||||
#define RES_BUFSZ 256
|
||||
class FormatBufferResource : public FormatBufferBase {
|
||||
public:
|
||||
FormatBufferResource(const char * format, ...);
|
||||
};
|
||||
|
||||
// Use stack for buffer
|
||||
template <size_t bufsz = 256>
|
||||
class FormatBuffer {
|
||||
class FormatBuffer : public FormatBufferBase {
|
||||
public:
|
||||
inline FormatBuffer(const char * format, ...);
|
||||
inline void append(const char* format, ...);
|
||||
inline void print(const char* format, ...);
|
||||
inline void printv(const char* format, va_list ap);
|
||||
operator const char *() const { return _buf; }
|
||||
|
||||
char* buffer() { return _buf; }
|
||||
int size() { return bufsz; }
|
||||
|
||||
private:
|
||||
FormatBuffer(const FormatBuffer &); // prevent copies
|
||||
char _buffer[bufsz];
|
||||
|
||||
protected:
|
||||
char _buf[bufsz];
|
||||
|
||||
inline FormatBuffer();
|
||||
};
|
||||
|
||||
template <size_t bufsz>
|
||||
FormatBuffer<bufsz>::FormatBuffer(const char * format, ...) {
|
||||
FormatBuffer<bufsz>::FormatBuffer(const char * format, ...) : FormatBufferBase(_buffer) {
|
||||
va_list argp;
|
||||
va_start(argp, format);
|
||||
jio_vsnprintf(_buf, bufsz, format, argp);
|
||||
|
@ -61,7 +75,7 @@ FormatBuffer<bufsz>::FormatBuffer(const char * format, ...) {
|
|||
}
|
||||
|
||||
template <size_t bufsz>
|
||||
FormatBuffer<bufsz>::FormatBuffer() {
|
||||
FormatBuffer<bufsz>::FormatBuffer() : FormatBufferBase(_buffer) {
|
||||
_buf[0] = '\0';
|
||||
}
|
||||
|
||||
|
@ -93,6 +107,7 @@ void FormatBuffer<bufsz>::append(const char* format, ...) {
|
|||
|
||||
// Used to format messages for assert(), guarantee(), fatal(), etc.
|
||||
typedef FormatBuffer<> err_msg;
|
||||
typedef FormatBufferResource err_msg_res;
|
||||
|
||||
// assertions
|
||||
#ifdef ASSERT
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue