1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* dln.c (aix_loaderror): use execerror for load error on AIX.

This can avoid SEGV reported by Perry Smith.  [Bug #2063]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kanemoto 2010-05-05 12:55:02 +00:00
parent bd21118627
commit 0882e74bf6
2 changed files with 21 additions and 38 deletions

View file

@ -1,3 +1,8 @@
Wed May 5 21:49:31 2010 Yutaka Kanemoto <kanemoto@ruby-lang.org>
* dln.c (aix_loaderror): use execerror for load error on AIX.
This can avoid SEGV reported by Perry Smith. [Bug #2063]
Wed May 5 20:37:54 2010 wanabe <s.wanabe@gmail.com>
* thread_win32.c (w32_wait_events): get GVL before handle interrupt

48
dln.c
View file

@ -1175,45 +1175,23 @@ static void
aix_loaderror(const char *pathname)
{
char *message[1024], errbuf[1024];
int i,j;
static const struct errtab {
int errnum;
const char * errstr;
} load_errtab[] = {
{L_ERROR_TOOMANY, "too many errors, rest skipped."},
{L_ERROR_NOLIB, "can't load library:"},
{L_ERROR_UNDEF, "can't find symbol in library:"},
{L_ERROR_RLDBAD,
"RLD index out of range or bad relocation type:"},
{L_ERROR_FORMAT, "not a valid, executable xcoff file:"},
{L_ERROR_MEMBER,
"file not an archive or does not contain requested member:"},
{L_ERROR_TYPE, "symbol table mismatch:"},
{L_ERROR_ALIGN, "text alignment in file is wrong."},
{L_ERROR_SYSTEM, "System error:"},
{L_ERROR_ERRNO, NULL}
};
#define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0]))
int i;
#define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1)
snprintf(errbuf, sizeof(errbuf), "load failed - %s. ", pathname);
snprintf(errbuf, sizeof(errbuf), "load failed - %s ", pathname);
message[0] = NULL;
if (!loadquery(L_GETMESSAGES, &message[0], sizeof(message)))
ERRBUF_APPEND(strerror(errno));
for(i = 0; message[i] && *message[i]; i++) {
int nerr = atoi(message[i]);
for (j=0; j<LOAD_ERRTAB_LEN; j++) {
if (nerr == load_errtab[j].errnum && load_errtab[j].errstr)
ERRBUF_APPEND(load_errtab[j].errstr);
}
while (isdigit(*message[i])) message[i]++;
if (loadquery(L_GETMESSAGES, &message[0], sizeof(message)) != -1) {
ERRBUF_APPEND("Please issue below command for detailed reasons:\n\t");
ERRBUF_APPEND("/usr/sbin/execerror ruby ");
for (i=0; message[i]; i++) {
ERRBUF_APPEND("\"");
ERRBUF_APPEND(message[i]);
ERRBUF_APPEND("\n");
ERRBUF_APPEND("\" ");
}
ERRBUF_APPEND("\n");
} else {
ERRBUF_APPEND(strerror(errno));
ERRBUF_APPEND("[loadquery failed]");
}
errbuf[strlen(errbuf)-1] = '\0'; /* trim off last newline */
dln_loaderror("%s", errbuf);
}
#endif